Home
Head's Up: I'm in the middle of upgrading my site. Most things are in place, but there are something missing and/or broken including image alt text. Please bear with me while I'm getting things fixed.

Find and Replace with String or RegEx

The simplest replacement is substituting one string for another with ` .replaceAll() `

js
const original = "the quick brown fox"

const updated = original.replaceAll('brown', 'green')

console.log(updated)
results start

This can also be done with a regular expression

TODO : See also : [TODO: Code shorthand span ] which only does one

This is an example using a regex. You can also use a string. TKTKTK make more examples including ones with functions and strings

js
const regex = /\d+s/g

const original = "There are 1000s and 1000s of corgis"

const updated = original.replace(regex, 'lots')

console.log(updated)
results start

More here : https : //developer.mozilla.org/en - US/docs/Web/JavaScript/Reference/Global _ Objects/String/replace