Getting text between 2 strings in JS Regex : <p>I have this JavaScript code:</p>

<pre><code>var str = "#foo#";
var regex = /(?&lt;=#)(.*)(?=#)/ig;
var result = str.replace(regex,"&lt;a href='https://www.google.com/search?q=$1'&gt;$1&lt;/a&gt;");
alert(result);
</code></pre>

<p>I want the text between surrounded by # to turn into a link to a google search. I would like get the text between #, not change it. Is there a way to do this?</p>
