I’m looking to automatically parse links that appear within a block of text, and add the appropriate anchor tags.
The function I came up with is:
function parse_links($string){
return preg_replace('#http://(.*?)\\s#i', '<a href="http://$1">$1</a>', $string);
}
Though I don’t know how robust this is. Any ideas, or criticisms of this approach? How do the major CMSes like vBulletin perform this type of parsing?