I want to replace a string by another. I found when the replaceValue contains \"$\", the replace will fail. So I am trying to escape \"$\" by
\"$\"
There is a way to call replace that allows us not to worry about escaping anything.
replace
var str = ..., reg = ...; function replaceString(replaceValue) { return str.replace(reg, function () { return replaceValue }); }