Possible Duplicate:
Replace URLs in text with HTML links
I'm passing the string variable which contains multiple urls, through function below to get same thing only with proper HTML links.
public function convertUrlsToLinks($text){
return preg_replace( '@(?<![.*">])\b(?:(?:https?|ftp|file)://|[a-z]\.)[-A-Z0-9+&#/%=~_|$?!:,.]*[A-Z0-9+&#/%=~_|$]@i', '<a href="\0" target="_blank">\0</a>', $text );
}
It doesn't work at all. What am I missing?
Code must skip existing links, <img>
's src
values (or something like that.)