wrapping anchor tags around a URL

From: Date: Mon, 23 Jan 2006 23:48:57 +0000
Subject: wrapping anchor tags around a URL
Groups: php.general 
Request: Send a blank email to php-general+get-229139@lists.php.net to get a copy of this message
I wrote a little function to put anchor tags around a URL. We're using it to make URL's in paragraphs of text linkable: function link_the_links($s) { return preg_replace('@(http://[^\s]+)@sm', '<a href="$1">$1</a>', $s); } Its only flaw (besides a goofy name) is that if a link comes at the end of a sentence, right before the period, the period ends up in the link, thus breaking the link. I've got to somehow ignore the trailing period if it is present. Any ideas? Richard K Miller

« previous php.general (#229139) next »