PHP reg expr. replace ALL URLs except img src URLs
<p>I have searched but havent been able to find my answer.
It follows like:</p>

<p>I would like to replace all URL in a string to links except the URLs within img src tag.</p>

<p>I have a regular expression for replacing all the URLs to links, but would like it to NOT replace the URLs within img src="" attribute.</p>

<p>How can i do this?</p>

<p>Here is the code for replacing all URLs:</p>

<pre><code> /*** make sure there is an http:// on all URLs ***/
$str = preg_replace("/([^\w\/])(www\.[a-z0-9\-]+\.[a-z0-9\-]+)/i", "$1http://$2",$str);
/*** make all URLs links ***/
$str = preg_replace("/([\w]+:\/\/[\w-?&amp;;#~=\.\/\@]+[\w\/])/i","&lt;a target=\"_blank\" href=\"$1\"&gt;$1&lt;/a&gt;",$str);`
</code></pre>

<p>/Regards </p>
