Touch 2.0.2 Sencha Docs

Ext.String

Files

A collection of useful static methods to deal with strings

Available since: 2.0.0

Defined By

Properties

Ext.String
view source
: RegExpprivate
...

Defaults to: /('|\)/g

Available since: 2.0.0

Ext.String
view source
: RegExpprivate
...

Defaults to: /([-.*+?^${}()|[\]\/\])/g

Available since: 2.0.0

Ext.String
view source
: RegExpprivate
...

Defaults to: /\{(\d+)\}/g

Available since: 2.0.0

Ext.String
view source
: RegExpprivate
...

Defaults to: /^[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u2028\u2029\u202f\u205f\u3000]+|[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u2028\u2029\u202f\u205f\u3000]+$/g

Available since: 2.0.0

Defined By

Methods

Ext.String
view source
( string ) : String
Capitalize the given string ...

Capitalize the given string

Available since: 2.0.0

Parameters

Returns

Ext.String
view source
( value, length, word ) : String
Truncate a string and add an ellipsis ('...') to the end if it exceeds the specified length ...

Truncate a string and add an ellipsis ('...') to the end if it exceeds the specified length

Available since: 2.0.0

Parameters

  • value : String

    The string to truncate

  • length : Number

    The maximum length to allow before truncating

  • word : Boolean

    True to try to find a common word break

Returns

Ext.String
view source
( string ) : String
Escapes the passed string for ' and \ ...

Escapes the passed string for ' and \

Available since: 2.0.0

Parameters

  • string : String

    The string to escape

Returns

Ext.String
view source
( string ) : String
Escapes the passed string for use in a regular expression ...

Escapes the passed string for use in a regular expression

Available since: 2.0.0

Parameters

Returns

Ext.String
view source
( string, value1, value2 ) : String
Allows you to define a tokenized string and pass an arbitrary number of arguments to replace the tokens. ...

Allows you to define a tokenized string and pass an arbitrary number of arguments to replace the tokens. Each token must be unique, and must increment in the format {0}, {1}, etc. Example usage:

var cls = 'my-class', text = 'Some text';
var s = Ext.String.format('<div class="{0}">{1}</div>', cls, text);
// s now contains the string: '<div class="my-class">Some text</div>'
       

Available since: 2.0.0

Parameters

  • string : String

    The tokenized string to be formatted

  • value1 : String

    The value to replace token {0}

  • value2 : String

    Etc...

Returns

Ext.String
view source
( value ) : String
Convert certain characters (&, <, >, and ") from their HTML character equivalents. ...

Convert certain characters (&, <, >, and ") from their HTML character equivalents.

Available since: 2.0.0

Parameters

  • value : String

    The string to decode

Returns

Ext.String
view source
( value ) : String
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.

Available since: 2.0.0

Parameters

  • value : String

    The string to encode

Returns

Ext.String
view source
( string, size, [character] ) : String
Pads the left side of a string with a specified character. ...

Pads the left side of a string with a specified character. This is especially useful for normalizing number and date strings. Example usage:

var s = Ext.String.leftPad('123', 5, '0');
// s now contains the string: '00123'
       

Available since: 2.0.0

Parameters

  • string : String

    The original string

  • size : Number

    The total length of the output string

  • character : String (optional)

    The character with which to pad the original string (defaults to empty string " ")

Returns

Ext.String
view source
( pattern, count, sep )
Returns a string with a specified number of repititions a given string pattern. ...

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, '/'); // = '--/--/--'

Available since: 2.0.0

Parameters

  • pattern : String

    The pattern to repeat.

  • count : Number

    The number of times to repeat the pattern (may be 0).

  • sep : String

    An option string to separate each pattern.

Ext.String
view source
( string, value, other ) : String
Utility function that allows you to easily switch a string between two alternating values. ...

Utility function that allows you to easily switch a string between two alternating values. The passed value is compared to the current string, and if they are equal, the other value that was passed in is returned. If they are already different, the first value passed in is returned. Note that this method returns the new value but does not change the current string.

    // alternate sort directions
    sort = Ext.String.toggle(sort, 'ASC', 'DESC');

    // instead of conditional logic:
    sort = (sort == 'ASC' ? 'DESC' : 'ASC');
       

Available since: 2.0.0

Parameters

  • string : String

    The current string

  • value : String

    The value to compare to the current string

  • other : String

    The new value to use if the string already equals the first value passed in

Returns

Ext.String
view source
( string ) : String
Trims whitespace from either end of a string, leaving spaces within the string intact. ...

Trims whitespace from either end of a string, leaving spaces within the string intact. Example: @example var s = ' foo bar '; alert('-' + s + '-'); //alerts "- foo bar -" alert('-' + Ext.String.trim(s) + '-'); //alerts "-foo bar-"

Available since: 2.0.0

Parameters

  • string : String

    The string to escape

Returns

Ext.String
view source
( url, string ) : Object
Appends content to the query string of a URL, handling logic for whether to place a question mark or ampersand. ...

Appends content to the query string of a URL, handling logic for whether to place a question mark or ampersand.

Available since: 2.0.0

Parameters

  • url : String

    The URL to append to.

  • string : String

    The content to append to the URL.

Returns

  • Object

    (String) The resulting URL