X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/6746dc89c47ed01b165cc1152533605f97eb8e8d..f562e4c6e5fac7bcb445985b99acbea4d706e6f0:/src/core/src/lang/String.js diff --git a/src/core/src/lang/String.js b/src/core/src/lang/String.js index 4e99f48a..1347982b 100644 --- a/src/core/src/lang/String.js +++ b/src/core/src/lang/String.js @@ -26,7 +26,7 @@ Ext.String = { escapeRegexRe: /([-.*+?^${}()|[\]\/\\])/g, /** - * Convert certain characters (&, <, >, and ') to their HTML character equivalents for literal display in web pages. + * Convert certain characters (&, <, >, and ") to their HTML character equivalents for literal display in web pages. * @param {String} value The string to encode * @return {String} The encoded text * @method @@ -53,7 +53,7 @@ Ext.String = { })(), /** - * Convert certain characters (&, <, >, and ') from their HTML character equivalents. + * Convert certain characters (&, <, >, and ") from their HTML character equivalents. * @param {String} value The string to decode * @return {String} The decoded text * @method @@ -221,6 +221,24 @@ var s = Ext.String.format('<div class="{0}">{1}</div>', cls, text); return format.replace(Ext.String.formatRe, function(m, i) { return args[i]; }); + }, + + /** + * Returns a string with a specified number of repititions a given string pattern. + * The pattern be separated by a different string. + * + * var s = Ext.String.repeat('---', 4); // = '------------' + * var t = Ext.String.repeat('--', 3, '/'); // = '--/--/--' + * + * @param {String} pattern The pattern to repeat. + * @param {Number} count The number of times to repeat the pattern (may be 0). + * @param {String} sep An option string to separate each pattern. + */ + repeat: function(pattern, count, sep) { + for (var buf = [], i = count; i--; ) { + buf.push(pattern); + } + return buf.join(sep || ''); } };