Class Index | File Index

Classes


Namespace $.js.String

Holds the methods used for manipulating strings. Some of them are already available in JavaScript 1.6, natively.
Defined in: core-js.js.

Namespace Summary
Constructor Attributes Constructor Name and Description
 
Holds the methods used for manipulating strings.
Method Summary
Method Attributes Method Name and Description
<static>  
$.js.String.escapeRegexp()
Escape special characters in regular expressions.
<static>  
$.js.String.escapeXML()
Convert significant characters into entities.
<static>  
$.js.String.stripTags()
Strip tags from a string.
<static>  
$.js.String.trim()
Trim whitespace from the start and the end of the string.
<static>  
$.js.String.trimLeft()
Trim whitespace from the start of the string.
<static>  
$.js.String.trimRight()
Trim whitespace from the end of the string.
<static>  
$.js.String.unescapeXML()
Decode significant characters from entities.
Namespace Detail
$.js.String
Holds the methods used for manipulating strings. Some of them are already available in JavaScript 1.6, natively.

By default, the global String.prototype object is extended to contain all the methods in this namespace, if they do not exists already. Thus, native String methods are not overwritten.

All of these methods use their this object. As such, you need to pass the correct this object.

In the examples provided for each method we will assume that the strings defined already have the methods. Thus code like string.trim() can be written directly.

Method Detail
<static> {String} $.js.String.escapeRegexp()
Escape special characters in regular expressions.
Returns:
{String} The string with the special characters escaped.

<static> {String} $.js.String.escapeXML()
Convert significant characters into entities. Any XML/HTML code has significant characters, like angle brackets and quotes. This method converts them to HTML entities, such that the resulting string can be used in Web pages without any problems.

The characters being encoded are:

Returns:
{String} The string with the special characters encoded.
See:
$.js.String.unescapeXML

<static> {String} $.js.String.stripTags()
Strip tags from a string.

Optionally, you may provide the list of tags to be stripped from the string. Each argument is considered a tag name.

If no argument is provided, then all the tags in the string are stripped.

Returns:
{String} The string with tags stripped.

<static> {String} $.js.String.trim()
Trim whitespace from the start and the end of the string.
var str = " \n test \n  ";
var str2 = str.trim();
// Now str2 = 'test'.
Returns:
{String} The string without any whitespace at the beginning, nor at the end.
See:
$.js.String.trimLeft
$.js.String.trimRight

<static> {String} $.js.String.trimLeft()
Trim whitespace from the start of the string.
var str = " \n test \n  ";
var str2 = str.trimLeft();
// Now str2 = "test \n  ".
Returns:
{String} The string without any whitespace at the beginning.
See:
$.js.String.trim
$.js.String.trimRight

<static> {String} $.js.String.trimRight()
Trim whitespace from the end of the string.
var str = " \n test \n  ";
var str2 = str.trimRight();
// Now str2 = " \n test".
Returns:
{String} The string without any whitespace at the end.
See:
$.js.String.trim
$.js.String.trimLeft

<static> {String} $.js.String.unescapeXML()
Decode significant characters from entities. This is the reverse method of $.js.String.escapeXML.
Returns:
{String} The string with the special characters decoded.
See:
$.js.String.escapeXML

Documentation generated by JsDoc Toolkit 2.1.0 on Thu Apr 23 2009 13:05:52 GMT+0300 (EEST)