title: using php preg_replace to change html link's href attribute
body: <p>I'm trying to replace all link href's in a large string with a different URL. With the following code It seems to replace only the 2nd link leaving the first one intact, can someone help me out?</p>
  
  <pre><code>$string_of_text = '&lt;a href="http://www.php.net/"&gt;PHP&lt;/a&gt; &lt;a href="http://www.apache.org/"&gt;Apache&lt;/a&gt;';
  echo preg_replace('/&lt;a(.*)href="(.*)"(.*)&gt;/','&lt;a$1href="javascript:alert(\'Test\');"$3&gt;',$string_of_text);
  </code></pre>