TypeScript String

14 functions

atstr.at(index: number): string | undefined

Returns the item at the given index (supports negative indices).

replaceAllstr.replaceAll(searchFor, replaceWith): string

Returns a new string with all matches of a pattern replaced.

matchAllstr.matchAll(regexp): IterableIterator<RegExpMatchArray>

Returns an iterator of all results matching a string against a regular expression.

trimStartstr.trimStart(): string

Removes whitespace from the beginning of a string.

trimEndstr.trimEnd(): string

Removes whitespace from the end of a string.

padStartstr.padStart(targetLength, padString?): string

Pads the current string with another string until the resulting string reaches the given length, applied from the start.

padEndstr.padEnd(targetLength, padString?): string

Pads the current string with another string until the resulting string reaches the given length, applied from the end.

repeatstr.repeat(count: number): string

Returns a new string which contains the specified number of copies of the string.

startsWithstr.startsWith(searchStr, position?): boolean

Determines whether a string begins with the characters of a specified string.

endsWithstr.endsWith(searchStr, endPosition?): boolean

Determines whether a string ends with the characters of a specified string.

includesstr.includes(searchStr, position?): boolean

Determines whether an array includes a certain value among its entries.

slicestr.slice(start, end?): string

Extracts a section of a string and returns it as a new string.

splitstr.split(separator, limit?): string[]

Divides a String into an ordered list of substrings.

template literal`Hello, ${name}!`

Embeds expressions within string literals using backtick syntax.