Adding HREFs to document's contents whenever regex appears in Javascript
<p>I'd like to find every occurrence of "needle/variable" in the document's contents and replace it with "&lt;a href="blahblah.com/needle/variable/">needle/variable&lt;/a>".</p>

<p>I'm trying to use: </p>

<pre><code>document.body.innerHTML = document.body.innerHTML.replace(/(needle\/(variable))/g, '&lt;a href="http://www.blahblah.com/' + $2 + '"&gt; '+$2+' &lt;/a&gt;');
</code></pre>

<p>but for some reason it's not capturing the $1 and $2. Also, is there a better way to be doing this? The content "needle/variable" that I'm looking at is not guaranteed to be anywhere specific, it could be anywhere in the document.</p>
