method String.replace
Private
String.replace(
searchValue: string | RegExp,
replaceValue: string,
): string

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

Parameters

searchValue: string | RegExp

A string or regular expression to search for.

replaceValue: string

A string containing the text to replace. When the searchValue is a RegExp, all matches are replaced if the g flag is set (or only those matches at the beginning, if the y flag is also present). Otherwise, only the first match of searchValue is replaced.

Return Type

string
String.replace(
searchValue: string | RegExp,
replacer: (
substring: string,
...args: any[],
) => string
,
): string

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

Parameters

searchValue: string | RegExp

A string to search for.

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

A function that returns the replacement text.

Return Type

string