what this replace function do?
<p>I came across some javascript code like this:</p>

<pre><code>selector = $this.attr('href')
selector = selector &amp;&amp; selector.replace(/.*(?=#[^\s]*$)/, '')
</code></pre>

<p>And I don't quite understand what the replace part do.Can someone explain that in detail?</p>

<p>Thanks,G</p>
