Find and Replace with String or RegEx
January - 2022
TODO: See also: .replaceAll()
This is an example using a regex. You can also use a string. TKTKTK make more examples including ones with functions and strings
const regex = /fox/i
const initialString = "The quick brown fox"
const newString = initialString.replace(regex, 'cat')
console.log(newString)
Outputs:
The quick brown cat
More here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace