diff --git a/src/lang/string.js b/src/lang/string.js index a7c0334..e581f63 100644 --- a/src/lang/string.js +++ b/src/lang/string.js @@ -42,6 +42,11 @@ Object.extend(String.prototype, (function() { * Returns the string with every occurence of a given pattern replaced by either * a regular string, the returned value of a function or a [[Template]] string. * The pattern can be a string or a regular expression. + * + *
Example
+ * + * ""hello".gsub(/([aeiou])/, '<#{1}>'); + * // => "hll" **/ function gsub(pattern, replacement) { var result = '', source = this, match; @@ -73,6 +78,11 @@ Object.extend(String.prototype, (function() { * Returns a string with the first count occurrences of pattern replaced by either * a regular string, the returned value of a function or a [[Template]] string. * The pattern can be a string or a regular expression. + * + *
Example
+ * + * "20091201".sub(/^(\d{4})(\d{2})(\d{2})$/, "#{1}-#{2}-#{3}"); + * // => "2009-12-01" **/ function sub(pattern, replacement, count) { replacement = prepareReplacement(replacement);