0

How would I tell Regex to not match a word that is already within a word in Javascript.

For example the text:

brown and white sandy

I dont want to select the 'and' within 'sandy' only the 'and' that is not within another word.

For some reason the following code does not work:

 correctedText = correctedText.replace(new RegExp('\band\b', 'g'), '/'); 
Dmitri
  • 579
  • 1
  • 9
  • 19

0 Answers0