Provides extensions to the base ECMAScript (JavaScript) String object by including static and instance methods. String Type Extensions

see

{@link http://msdn.microsoft.com/en-us/library/bb397472(v=vs.100).aspx}

Index

Index signatures

Construct signatures

Properties

Methods

Index signatures

(value?: any): string

Parameters

  • value?: any optional

Returns

string

(index: number): string

Parameters

  • index: number

Returns

string

Construct signatures

constructor(value?: any): String

Parameters

  • value?: any optional

Returns

String

Properties

public length: number

Returns the length of a String object.

public prototype: String

Methods

public charAt(pos: number): string

Returns the character at the specified index.

Parameters

  • pos: number

    The zero-based index of the desired character.

Returns

string

public charCodeAt(index: number): number

Returns the Unicode value of the character at the specified location.

Parameters

  • index: number

    The zero-based index of the desired character. If there is no character at the specified index, NaN is returned.

Returns

number

public concat(strings?: Array<string>): string

Returns a string that contains the concatenation of two or more strings.

Parameters

  • strings?: Array<string> optional

    The strings to append to the end of the string.

Returns

string

public endsWith(suffix: string): boolean

Formats a number by using the invariant culture.

Parameters

  • suffix: string

Returns

boolean

true if the end of the String object matches suffix; otherwise, false.

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

Replaces each format item in a String object with the text equivalent of a corresponding object's value.

Parameters

  • format: string
  • args?: Array<any> optional

Returns

string

A copy of the string with the formatting applied.

public fromCharCode(codes?: Array<number>): string

Parameters

  • codes?: Array<number> optional

Returns

string

public indexOf(searchString: string, position?: number): number

Returns the position of the first occurrence of a substring.

Parameters

  • searchString: string

    The substring to search for in the string

  • position?: number optional

    The index at which to begin searching the String object. If omitted, search starts at the beginning of the string.

Returns

number

public lastIndexOf(searchString: string, position?: number): number

Returns the last occurrence of a substring in the string.

Parameters

  • searchString: string

    The substring to search for.

  • position?: number optional

    The index at which to begin searching. If omitted, the search begins at the end of the string.

Returns

number

public localeCompare(that: string): number

Determines whether two strings are equivalent in the current locale.

Parameters

  • that: string

    String to compare to target string

Returns

number

public localeFormat(format: string, args?: Array<any>): string

Replaces the format items in a String object with the text equivalent of a corresponding object's value. The current culture is used to format dates and numbers.

Parameters

  • format: string
  • args?: Array<any> optional

Returns

string

A copy of the string with the formatting applied.

public match(regexp: string): Array<string>

Matches a string with a regular expression, and returns an array containing the results of that search.

Parameters

  • regexp: string

    A variable name or string literal containing the regular expression pattern and flags.

Returns

Array<string>

public match(regexp: RegExp): Array<string>

Matches a string with a regular expression, and returns an array containing the results of that search.

Parameters

  • regexp: RegExp

    A regular expression object that contains the regular expression pattern and applicable flags.

Returns

Array<string>

public replace(searchValue: string, replaceValue: string): string

Replaces text in a string, using a regular expression or search string.

Parameters

  • searchValue: string

    A String object or string literal that represents the regular expression

  • replaceValue: string

    A String object or string literal containing the text to replace for every successful match of rgExp in stringObj.

Returns

string

public replace(searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string

Replaces text in a string, using a regular expression or search string.

Parameters

  • searchValue: string

    A String object or string literal that represents the regular expression

  • replaceValue: (substring: string, ...args: any[]) => string

    A function that returns the replacement text.

Returns

string

public replace(searchValue: RegExp, replaceValue: string): string

Replaces text in a string, using a regular expression or search string.

Parameters

  • searchValue: RegExp

    A Regular Expression object containing the regular expression pattern and applicable flags

  • replaceValue: string

    A String object or string literal containing the text to replace for every successful match of rgExp in stringObj.

Returns

string

public replace(searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string

Replaces text in a string, using a regular expression or search string.

Parameters

  • searchValue: RegExp

    A Regular Expression object containing the regular expression pattern and applicable flags

  • replaceValue: (substring: string, ...args: any[]) => string

    A function that returns the replacement text.

Returns

string

public search(regexp: string): number

Finds the first substring match in a regular expression search.

Parameters

  • regexp: string

    The regular expression pattern and applicable flags.

Returns

number

public search(regexp: RegExp): number

Finds the first substring match in a regular expression search.

Parameters

  • regexp: RegExp

    The regular expression pattern and applicable flags.

Returns

number

public slice(start?: number, end?: number): string

Returns a section of a string.

Parameters

  • start?: number optional

    The index to the beginning of the specified portion of stringObj.

  • end?: number optional

    The index to the end of the specified portion of stringObj. The substring includes the characters up to, but not including, the character indicated by end. If this value is not specified, the substring continues to the end of stringObj.

Returns

string

public split(separator: string, limit?: number): Array<string>

Split a string into substrings using the specified separator and return them as an array.

Parameters

  • separator: string

    A string that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned.

  • limit?: number optional

    A value used to limit the number of elements returned in the array.

Returns

Array<string>

public split(separator: RegExp, limit?: number): Array<string>

Split a string into substrings using the specified separator and return them as an array.

Parameters

  • separator: RegExp

    A Regular Express that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned.

  • limit?: number optional

    A value used to limit the number of elements returned in the array.

Returns

Array<string>

public substr(from: number, length?: number): string

Gets a substring beginning at the specified location and having the specified length.

Parameters

  • from: number

    The starting position of the desired substring. The index of the first character in the string is zero.

  • length?: number optional

    The number of characters to include in the returned substring.

Returns

string

public substring(start: number, end?: number): string

Returns the substring at the specified location within a String object.

Parameters

  • start: number

    The zero-based index number indicating the beginning of the substring.

  • end?: number optional

    Zero-based index number indicating the end of the substring. The substring includes the characters up to, but not including, the character indicated by end. If end is omitted, the characters from start through the end of the original string are returned.

Returns

string

public toLocaleLowerCase(): string

Converts all alphabetic characters to lowercase, taking into account the host environment's current locale.

Returns

string

public toLocaleUpperCase(): string

Returns a string where all alphabetic characters have been converted to uppercase, taking into account the host environment's current locale.

Returns

string

public toLowerCase(): string

Converts all the alphabetic characters in a string to lowercase.

Returns

string

public toString(): string

Returns a string representation of a string.

Returns

string

public toUpperCase(): string

Converts all the alphabetic characters in a string to uppercase.

Returns

string

public trim(): string

Removes leading and trailing white-space characters from a String object.

Returns

string

A copy of the string with all white-space characters removed from the start and end of the string.

public trimEnd(): string

Removes trailing white-space characters from a String object.

Returns

string

A copy of the string with all white-space characters removed from the end of the string.

public trimStart(): string

Removes leading white-space characters from a String object.

Returns

string

A copy of the string with all white-space characters removed from the start of the string.