Articles
Regex to convert urls to links
- Details
- Published on Wednesday, 02 November 2011 15:42
A handy PHP regex to replace urls in a section of text to links.
$text = preg_replace('#(?])((http|ftp)s?://[^<>\s]+)#i', '\\0', $text );
A handy PHP regex to replace urls in a section of text to links.
$text = preg_replace('#(?])((http|ftp)s?://[^<>\s]+)#i', '\\0', $text );