I want to replace the string with another. I found that if replaceValue contains "$" , the replacement will fail. So first I try to avoid the "$" on the "$$" . The code is as follows:
var str = ..., reg = ...; function replaceString(replaceValue) { str.replace(reg, replaceValue.replace(/\$/g, '$$$$')); }
But I think this is ugly, since I need to write 4 dollar signs.
Are there any other characteristics that I need to escape? And is there a better way to do this?
source share