Say I had the following string:
var str = '(1 + foo + 3) / bar';
And I want to replace all strings just with the letter 'x'. I tried:
str = str.replace(/\w/g, 'x');
This results in:
(x + xxx + x) / xxx
Instead, I would like the result to be:
(1 + x + 3) / x
How would I do this? How would I find just the words that don't have digits and replace the word to a single letter?
/a-zA-Z/instead, since\wcontains numbers : w3schools.com/jsref/jsref_regexp_wordchar.asp