Skip to content

replace

replace(target, search, replace)

Replaces the first occurrence of search string or regular expression in target string with replace string.

ts
replace("hello world", "world", "universe"); // "hello universe"
replace("hello world", /o/g, "0"); // "hell0 w0rld"
ts
pipe("hello world", replace("world", "universe")); // "hello universe"
pipe("hello world", replace(/o/g, "0")); // "hell0 w0rld"