Skip to content

replaceAll

String.replaceAll(target, search, replace)

Replaces all occurrences of search string or regular expression in target string with replace string.

Example

ts
import { String } from "@monstermann/string";

String.replaceAll("hello world world", "world", "universe"); // "hello universe universe"
String.replaceAll("hello world", /o/g, "0"); // "hell0 w0rld"
ts
import { String } from "@monstermann/string";

pipe("hello world world", String.replaceAll("world", "universe")); // "hello universe universe"
pipe("hello world", String.replaceAll(/o/g, "0")); // "hell0 w0rld"