Prototypes: String
| Method Attributes | Method Name and Description |
|---|---|
|
Escape XML relevant symbols from string.
|
|
|
Unescape XML relevant symbols from string.
|
|
|
test(exp, flag)
Searches a string for a given string or regular expression.
|
|
|
toNumber()
Converts a string to a number.
|
|
|
camelize()
Extend String Object by add camelize function requires Bicycle Chain |
|
|
trim()
Removes the leading and trailing spaces off a string. requires Bicycle Chain |
Method Detail
{String}
escapeXML()
Escape XML relevant symbols from string.
var myString = "This is a sample text";
myString.escapeXML(); // returns "<b>This is a sample text</b>"
- Returns:
- {String} Returns the escaped string
- See:
- liberty - Basic JavaScript Library 0.1
{String}
unescapeXML()
Unescape XML relevant symbols from string.
- Returns:
- {String} Returns the unescaped string
- See:
- liberty - Basic JavaScript Library 0.1
{Bool}
test(exp, flag)
Searches a string for a given string or regular expression.
Author: Valerio Proietti.
Author: Valerio Proietti.
var myString = "This is a SAMPLE text";
myString.test("sample"); // returns false
myString.test("sample","i"); // returns true
myString.test(/SAMPLE/); // returns true
- Parameters:
- {String|Object} exp
- String or Regular expression to match
- {String} flag Optional
- If exp is a string function accepts a flag, for example "i" will ignore uppercase or lowercase
- Returns:
- {Bool} true if a match is found
- See:
- See http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Guide:Regular_Expressions for RegExp info.
- Mootools 1.0
{Number}
toNumber()
Converts a string to a number. If the string is mixed, not numerical characters are stripped out (except "." and "-"). Accepts both integer and float conversions.
number_1="text_01".toString(); // 01
number_2="70.567".toString(); // 70.567
number_3="(-70.567)".toString(); // -70.567
- Returns:
- {Number} The parsed string as integer of float
- See:
- ExtendDOM (String.js) - by Mega69 http://www.sitomega.net/projects/extendDOM/main.php
{String}
camelize()
Extend String Object by add camelize function
"my-string-with-hypens".camelize();
// returns "myStringWithHypens"
- Returns:
- {String} a camelized string
- See:
- camelCase
{String}
trim()
Removes the leading and trailing spaces off a string.
- Returns:
- {String} The trimmed string