note 34999 added to function.preg-replace

From: Date: Thu, 14 Aug 2003 17:35:20 +0000
Subject: note 34999 added to function.preg-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-54169@lists.php.net to get a copy of this message
The code below is a bit modified variant of one of automatic-hyperlinkers above (accepts http, https, ftp protocol URLs, also email address), this one also accpets Apache /~user functionality: $text = preg_replace("/(?:^|\b)((((http|https|ftp):\/\/)|(www\.)) ([\w\.]+)([,:%#&\/?~=\w+\.-]+))(?:\b|$)/is", "<a href=\"$1\" target=\"_blank\">$1</a>", $text); $text = preg_replace("/(([\w\.]+))(@)([\w\.]+)\b/i","<a href=\"mailto:$0\">$0</a>",$text); ---- Manual Page -- http://www.php.net/manual/en/function.preg-replace.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+34999 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+34999&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+34999&report=yes

« previous php.notes (#54169) next »