title: PHP Regular expression to replace link url
body: <p>I need to add <strong><code>href="</code></strong> before an <strong><code>http://</code></strong> if this <strong><code>http://</code></strong> doesn't follow <strong><code>href="</code></strong> or <strong><code>src="</code></strong></p>
  
  <p>Following code partly works. Partly means it considers <strong><code>&lt;a href="</code></strong> only but not <strong><code>src="</code></strong></p>
  
  <pre><code>$str= preg_replace( 
      "/(?&lt;!a href=\")((http|ftp)+(s)?:\/\/[^&lt;&gt;\s]+)/i", 
      "&lt;a href=\"\\0\"&gt; target=\"blank\"&gt;\\0&lt;/a&gt;", 
      $str
  );
  </code></pre>
  
  <p>Thank you guys in advance for your reply.</p>