title: Replace string in URL with javascript
body: <p>I thought this was trivial but couldn't solve it out :(</p>
  
  <p>I want to change a param passed in mu url with javascript.</p>
  
  <pre><code>var fullurl = window.location;
  //do dome stuff to find var url.
  fullurl.replace(/sort:.*\/direction:.*/g,'sort:' + url + '/direction:asc');
  </code></pre>
  
  <p>Basically there is a url like: <a href="http://example.com/article/" rel="nofollow noreferrer">http://example.com/article/</a> or <a href="http://example.com/article/sort:author/direction:asc" rel="nofollow noreferrer">http://example.com/article/sort:author/direction:asc</a></p>
  
  <p>I the first case I don't want anything to be changed. In the second I want to replace the <code>sort:</code> with <code>sort:url</code> .</p>
  
  <p>the above code doesn't seem to do anything. I think the problem is that the regexp isn't parsed, and it returns a url with <code>.*</code> and <code>\/</code> inside</p>
  
  <p>any help? thanks</p>