I recently wrote a variable parsing framework that up until now, worked very well. When writing some financial tracking software using this framework, I ran into the following issues.
If:
string="%{data}";
Then:
console.log(string.replace(/%\/?{(\S[^\%{}]*)}/,"$5000"));
Yields $5000
.
This is how it is intended to work.
However, if I try the following:
console.log(string.replace(/%\/?{(\S[^\%{}]*)}/,"$15000"));
I get data5000
.
I'm guessing that $1
is a variable used within JavaScripts replace()
method. Am I right? If so, is there anyway I can change String.prototype.replace()
to use another variable? This also leads me to wonder if the scope for the replace method is even declared...