Class String

Index

Methods

Methods

public static capitalize(string?: string): string

[Method] Capitalize the given string

Parameters

  • string?: string optional

    String

Returns

string

String

public static ellipsis(value?: string, length?: number, word?: boolean): string

[Method] Truncate a string and add an ellipsis to the end if it exceeds the specified length

Parameters

  • value?: string optional

    String The string to truncate.

  • length?: number optional

    Number The maximum length to allow before truncating.

  • word?: boolean optional

    Boolean true to try to find a common word break.

Returns

string

String The converted text.

public static escape(string?: string): string

[Method] Escapes the passed string for and

Parameters

  • string?: string optional

    String The string to escape.

Returns

string

String The escaped string.

public static escapeRegex(string?: string): string

[Method] Escapes the passed string for use in a regular expression

Parameters

  • string?: string optional

    String

Returns

string

String

public static format(string: string, values?: Array<any>): string

[Method] Allows you to define a tokenized string and pass an arbitrary number of arguments to replace the tokens

Parameters

  • string: string

    String The tokenized string to be formatted.

  • values?: Array<any> optional

    String... First param value to replace token {0}, then next param to replace {1} etc.

Returns

string

String The formatted string.

public static htmlDecode(value?: string): string

[Method] Convert certain characters amp lt and from their HTML character equivalents

Parameters

  • value?: string optional

    String The string to decode.

Returns

string

String The decoded text.

public static htmlEncode(value?: string): string

[Method] Convert certain characters amp lt and to their HTML character equivalents for literal display in web pages

Parameters

  • value?: string optional

    String The string to encode.

Returns

string

String The encoded text.

public static leftPad(string?: string, size?: number, character?: string): string

[Method] Pads the left side of a string with a specified character

Parameters

  • string?: string optional

    String The original string.

  • size?: number optional

    Number The total length of the output string.

  • character?: string optional

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

Returns

string

String The padded string.

public static repeat(pattern?: string, count?: number, sep?: string)

[Method] Returns a string with a specified number of repetitions a given string pattern

Parameters

  • pattern?: string optional

    String The pattern to repeat.

  • count?: number optional

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

  • sep?: string optional

    String An option string to separate each pattern.

public static toggle(string?: string, value?: string, other?: string): string

[Method] Utility function that allows you to easily switch a string between two alternating values

Parameters

  • string?: string optional

    String The current string.

  • value?: string optional

    String The value to compare to the current string.

  • other?: string optional

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

Returns

string

String The new value.

public static trim(string?: string): string

[Method] Trims whitespace from either end of a string leaving spaces within the string intact

Parameters

  • string?: string optional

    String The string to escape

Returns

string

String The trimmed string

public static urlAppend(url?: string, string?: string): string

[Method] Appends content to the query string of a URL handling logic for whether to place a question mark or ampersand

Parameters

  • url?: string optional

    String The URL to append to.

  • string?: string optional

    String The content to append to the URL.

Returns

string

String The resulting URL.