A cut down version of my code sort of looks like this:
string="test test testtest testtest test";
replacer="test";
string=string.replace(new RegExp(' '+replacer+' ','gi')," REPLACED ");
Now, I want to replace a word only if there's a space surrounding it, The code actually works fine but I'm just wondering why the one below which would be better in my case doesn't work.
RegExp('\s'+replacer+'\s','gi')