strip():Remove the blanks on both sides of the string, for example " jj ".strip() returns "jj"
stripTags():Remove the html tag from the string
stripScripts():Remove javascript code snippets from strings
extractScripts():Returns the javascript code in the string, and returns the array
evalScripts():Execute javascript code in string
escapeHTML():Convert the html code in the string into a format that can be displayed directly, for example, converting < to <, there is a bug in ie6. The string returned by performing this operation turns multiple blanks together into one, so many new lines and other things are removed.
unescapeHTML():The reverse process of escapeHTML
truncate(length, truncation):Truncation, for example "abcdefghigkl".truncate(10) returns abcdefg..., truncation defaults to "..."toQueryParams(separator)/parseQuery(separator):Convert a querystring into a hash table (actually an object. In javascript, objects can be used as hash tables, because the properties or methods of objects can be accessed through object[propertyName])
toArray():return (''), converted into a character array
camelize():Convert background-color form to backgroundColor form, used in style/css
capitalize():Returns a string with capital letters
inspect(useDoubleQuotes):Returns the representation of the string, for example "sdfj\"sfa".inspect() returns "'sdfj"sfa'"
gsub(pattern, replacement):pattern is a regular expression, replacement is a function (or a template string). Use replacement for each part of the matching pattern in the string, and then replace the value returned by replacement with the original matching part, such as "skdjfAsfdjkAdk".gsub(/A/,function(match){return match[0].toLowerCase()}), convert all A of the string into a. Note that do not add the g option in the pattern, because gsub will recursively execute the match method
sub(pattern, replacement, count) :Another form of gsub, but the number of executions can be set
scan(pattern, iterator):It's similar to gsub, but returns the string itself, that is, iterator is executed for each match in the pattern, but does not return the replaced string "skdjfAsfdjkAdk".gsub(/A/,function(){alert 'have a A'})
underscore(): 'borderBottomWidth'.underscore() -> 'border_bottom_width'
dasherize(): 'Hello_World'.dasherize() -> 'Hello-World'
Template template class:
How to use:
var template = new Template(replacement, pattern);
(object) is a bit like a template in php, by default (no pattern provided) replaces the object's property value with something in the form of {propertyName}
stripTags():Remove the html tag from the string
stripScripts():Remove javascript code snippets from strings
extractScripts():Returns the javascript code in the string, and returns the array
evalScripts():Execute javascript code in string
escapeHTML():Convert the html code in the string into a format that can be displayed directly, for example, converting < to <, there is a bug in ie6. The string returned by performing this operation turns multiple blanks together into one, so many new lines and other things are removed.
unescapeHTML():The reverse process of escapeHTML
truncate(length, truncation):Truncation, for example "abcdefghigkl".truncate(10) returns abcdefg..., truncation defaults to "..."toQueryParams(separator)/parseQuery(separator):Convert a querystring into a hash table (actually an object. In javascript, objects can be used as hash tables, because the properties or methods of objects can be accessed through object[propertyName])
toArray():return (''), converted into a character array
camelize():Convert background-color form to backgroundColor form, used in style/css
capitalize():Returns a string with capital letters
inspect(useDoubleQuotes):Returns the representation of the string, for example "sdfj\"sfa".inspect() returns "'sdfj"sfa'"
gsub(pattern, replacement):pattern is a regular expression, replacement is a function (or a template string). Use replacement for each part of the matching pattern in the string, and then replace the value returned by replacement with the original matching part, such as "skdjfAsfdjkAdk".gsub(/A/,function(match){return match[0].toLowerCase()}), convert all A of the string into a. Note that do not add the g option in the pattern, because gsub will recursively execute the match method
sub(pattern, replacement, count) :Another form of gsub, but the number of executions can be set
scan(pattern, iterator):It's similar to gsub, but returns the string itself, that is, iterator is executed for each match in the pattern, but does not return the replaced string "skdjfAsfdjkAdk".gsub(/A/,function(){alert 'have a A'})
underscore(): 'borderBottomWidth'.underscore() -> 'border_bottom_width'
dasherize(): 'Hello_World'.dasherize() -> 'Hello-World'
Template template class:
How to use:
var template = new Template(replacement, pattern);
(object) is a bit like a template in php, by default (no pattern provided) replaces the object's property value with something in the form of {propertyName}