Do any of the existing JavaScript frameworks have a non-regex replace()
function,
or has this already been posted on the web somewhere as a one-off function?
I had exactly the same problem searching for a non-regex javascript string replace() method. My solution was to use a combination of split() and join():
"some text containing regex interpreted characters: $1.00".split("$").join("£");
which gives:
"some text containing regex interpreted characters: £1.00"
compare with replace():
"some text containing regex interpreted characters: $1.00".replace(new RegExp("$"),"£")
which bizarrely gives:
"some text containing regex interpreted characters: $1.00£"