TypeScript文字列replaceAll
at

replaceAll文字列

matchAll

一致するすべての部分を置換します。

構文

str.replaceAll(searchFor, replaceWith): string

使用例

下記の値を入力するとサンプルに即時反映されます。

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