I want to replace all occurences of a pattern in a string by another string. For example, lets convert all \"$\" to \"!\":
\"$$$\" -> \"!!!\"
You can give the regest as a string and provide a third argument for the flags you want
https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String/replace
"$$$".replace("$", "!", "g");