You can backreference like this in JavaScript:
var str = \"123 $test 123\"; str = str.replace(/(\\$)([a-z]+)/gi, \"$2\");
This would (quite
Pass a function as the second argument to replace:
replace
str = str.replace(/(\$)([a-z]+)/gi, myReplace); function myReplace(str, group1, group2) { return "+" + group2 + "+"; }
This capability has been around since Javascript 1.3, according to mozilla.org.