I’m replacing a bunch of values in a regex with dollar amounts. The problem is that in IE, if I attempt to replace with an amount of $0 (or, theoretically, $1—$9), the replace never occurs since the it’s trying to replace a non-existant group:
'foo'.replace(/f/g, '$0');
I want the result of that replacement to be “$0oo”, which it is in Chrome & FF, but not IE9 (haven’t tried other versions of IE).
Chrome & FF have an “issue” with the following, in that I can’t figure out how to replace with a literal $1:
'foo'.replace(/(f)/g, '$1')
Write
"$$0"to escape the$sign.