replace

Bun

Symbol

CString.replace

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

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

@param searchValue

A string or regular expression to search for.

@param replaceValue

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.

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

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

@param searchValue

A string to search for.

@param replacer

A function that returns the replacement text.

replace(searchValue: { [replace](string: string, replaceValue: string): string }, replaceValue: string): string

Passes a string and replaceValue to the [Symbol.replace] method on searchValue. This method is expected to implement its own replacement algorithm.

@param searchValue

An object that supports searching for and replacing matches within a string.

@param replaceValue

The replacement text.

replace(searchValue: { [replace](string: string, replacer: (substring: string, ...args: any[]) => string): string }, replacer: (substring: string, ...args: any[]) => string): string

Replaces text in a string, using an object that supports replacement within a string.

@param searchValue

A object can search for and replace matches within a string.

@param replacer

A function that returns the replacement text.