Replaces all occurrences of a substring or pattern in a string.
The original string.
The substring or regular expression to search for.
The string to replace matches with.
A new string with all matches replaced.
1.1.0
replaceAll("hello world", "l", "L"); // "heLLo worLd"replaceAll("foo bar foo", /foo/g, "baz"); // "baz bar baz" Copy
replaceAll("hello world", "l", "L"); // "heLLo worLd"replaceAll("foo bar foo", /foo/g, "baz"); // "baz bar baz"
Replaces all occurrences of a substring or pattern in a string.