Basically, I'm trying to replace parts of a string using elements from an associative array. However, I need to grab elements based on backreferences generated from capturing groups in a replace() expression.
Using the first capturing group, I created this code, which doesn't work:
content = content.replace(/%(\w+)%/g,this.vars["$1"]);
(The regex works fine... I just can't get it to grab the array element.)
How would I go about implementing something like this?