title: Greasemonkey - regex in javascript to change links
body: <p>I'm trying to change the url's of a webpage on the fly using greasemonkey.</p>
  
  <p><strong>Example of subject to be changed :</strong></p>
  
  <pre><code>&lt;p&gt;&lt;a rel="nofollow" href="http://site.com/goto/http_rapidshare_com_files_1401021221_SK_RG_X_FLAWL3SS_part01_rar/11609/107" rel="nofollow"&gt;http://rapidshare.com/files/1401021221/SK.RG.X.FLAWL3SS.part01.rar&lt;/a&gt;&lt;/p&gt;
  &lt;p&gt;&lt;a rel="nofollow" href="http://site.com/goto/http_rapidshare_com_files_3525685465_1_3_3_8_com_Parenthood_2010_S03E07_720p_HDTV_X264_DIMENSION_mkv/11598/51" rel="nofollow"&gt;http://rapidshare.com/files/3525685465/1-3-3-8.com_Parenthood.2010.S03E07.720p.HDTV.X264-DIMENSION.mkv&lt;/a&gt;&lt;/p&gt;
  </code></pre>
  
  <p><strong>GreaseMonkey Script:</strong></p>
  
  <pre><code>var els = document.getElementsByTagName("*");
  for(var i = 0, l = els.length; i &lt; l; i++) {
    var el = els[i];
     el.innerHTML = el.innerHTML.replace(/&lt;p&gt;&lt;a rel="nofollow" href=".*?" rel="nofollow"&gt;(.*?)&lt;\/a&gt;&lt;\/p&gt;/img, '&lt;p&gt;&lt;a rel="nofollow" href="$1" rel="nofollow"&gt;$1&lt;/a&gt;&lt;p&gt;');
  }
  </code></pre>
  
  <p><strong>Desired Output :</strong></p>
  
  <pre><code>&lt;p&gt;&lt;a rel="nofollow" href="http://rapidshare.com/files/1401021221/SK.RG.X.FLAWL3SS.part01.rar" rel="nofollow"&gt;http://rapidshare.com/files/1401021221/SK.RG.X.FLAWL3SS.part01.rar&lt;/a&gt;&lt;/p&gt;
  &lt;p&gt;&lt;a rel="nofollow" href="http://rapidshare.com/files/3525685465/1-3-3-8.com_Parenthood.2010.S03E07.720p.HDTV.X264-DIMENSION.mkv" rel="nofollow"&gt;http://rapidshare.com/files/3525685465/1-3-3-8.com_Parenthood.2010.S03E07.720p.HDTV.X264-DIMENSION.mkv&lt;/a&gt;&lt;/p&gt;
  </code></pre>
  
  <p>Basically, the regex above should change the href (<strong>http://site.com/goto/http_rapidshare_com_files_1401021221_SK_RG_X_FLAWL3SS_part01_rar/11609/107</strong>) to the visible text of the url (<strong>http://rapidshare.com/files/1401021221/SK.RG.X.FLAWL3SS.part01.rar</strong>) but for some reason it doesn't, any idea why?  </p>
  
  <p>Thank you all!<br>
  regards,<br>
  Lob</p>