This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
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 ;)