Articles

Regex to convert urls to links

A handy PHP regex to replace urls in a section of text to links.

$text = preg_replace('#(?])((http|ftp)s?://[^<>\s]+)#i', '\\0', $text );