note 29166 added to function.preg-replace

From: Date: Tue, 04 Feb 2003 23:18:16 +0000
Subject: note 29166 added to function.preg-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-43417@lists.php.net to get a copy of this message
As a rendition to the link replacement scripts from above... for the regular link replacement, if there was a dash in the link, it would nt function properly. $text = preg_replace( "/\b((http(s?):\/\/)|(www\.))([\w\.-]+)([\/\w+\.]+)\b/i", "<a href=\"http$3://$4$5$6\">$4$5$6</a>", $text); ... the above code is a fix to that. $text = preg_replace("/\b([\w\.]+)(@)([\w\.-]+)\b/i", "<a href=\"mailto:$0\">$0</a>", $text); ... that is the fix for the email replacemnt. Hope that helps someone... -- http://www.php.net/manual/en/function.preg-replace.php http://master.php.net/manage/user-notes.php?action=edit+29166 http://master.php.net/manage/user-notes.php?action=delete+29166 http://master.php.net/manage/user-notes.php?action=reject+29166

« previous php.notes (#43417) next »