Oh sorry, I meant like this:
$text = preg_replace('/[^\\"](?:(http:\\/\\/)|(www\\.))(\\S+\\b\\/?)([[:punct:]]*)(\\s|$)/i', '<a href="http://$2$3">$2$3</a>', $text);
Here's what I used in mine:
//"url" tag code
$info = preg_replace('/[url=((http|ftp):\/\/([\"]+?))]([<>]*?)[\/url]/i','<a href="\1">\4</a>',$info);
//Convert text URLs into hyperlinks (NOTE: Won't work if full text is URL)
$info = preg_replace('/((http|ftp):\/\/[a-zA-Z0-9]+(.[-a-zA-Z0-9]+).[a-zA-Z]{2,4}(\/[\s<>[]|\"\\]+))[\s]/i','<a href="\1">\1</a>',$info);
$info = preg_replace('/\s/i','<a href="\1">\1</a>',$info);
$info = preg_replace('/([\s])(www.[-a-zA-Z0-9]+.[a-zA-Z0-9]{2,4})/i','\1<a href="http://\2">\2</a>',$info); //This one checks for www.whatever.dom (no http: etc)
Note: I didn't put them in php tags because I didn't want to go in and double up all of my slashes that the 'php' tag likes to erase
And the [\"] in front means "http" or "ftp" won't have a quote in front.
Looking at them now, I see my regular expressions could use a little tweaking 😃