I have some code that will turn a normal text string starting with http: to a clickable link, but it screws it up if the code is an image code or some other reference. Can someone help me so if the text is displaying an image it won't parse it.

Here is the code
PHP Code:
$text ereg_replace("(((ftp://|http://|https://){1})[a-zA-Z0-9@:%_.~#-\?&]+[a-zA-Z0-9@:%_~#\?&/])""<A HREF=\"\\1\" TARGET=\"_blank\">\\1</A>"$text);