I want to replace all occurences of a pattern in a string by another string. For example, lets convert all \"$\" to \"!\":
\"$$$\" -> \"!!!\"
try this:
function replaceAll(txt, replace, with_this) { return txt.replace(new RegExp(replace, 'g'),with_this); }