I have tried the following:
var stringToBeReplaced = "$";
var result = stringToBeReplaced.replace("$", "$$$$");
It works in modern browsers and I get "$$"
in result
. But to my surprise, when I run it over IE8 or older, I get "$$$$"
in result
. Is it a browser bug? Is there a cross browser solution avoiding browser detection? Just vainilla js please, no frameworks.