TypeScriptStringreplaceAll
at

replaceAllString

matchAll

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

Syntax

str.replaceAll(searchFor, replaceWith): string

Example

Enter values below to update the example in real time.

const
str
console
replaceAll
const str = "foo bar foo";
console.log(str.replaceAll("foo", "baz")); // "baz bar baz"