First off, isn't the vertical pipe significant to a regex? It would need to be escaped.
Secondly, I don't believe "$1" will have any meaning outside of the regex itself (I actually thought backreferences were in the form \n, but I've only rarely used them in JS). You might have to exec() the regex to capture the values and do the eval() replacement.
I'd also consider just using any of the existing templating engines rather than rolling your own ;)
subject: calling a function with a backreference in String.Replace()