Supposed I have a string foo that may have regexp special characters (eg a file path).
I have a string x
x.replace(foo, 'bar');
But I don’t want foo to be interpretted as a regexp, I just want it to replace the literal string foo with ‘bar’.
How do I accomplish this?
If
foois a string, then it wont be interpretted as a regexp, it will just replace the literal string foo with'bar'."aaa /bbb/ ccc".replace("/bbb/", "eee")returns"aaa eee ccc".