note 32039 added to function.preg-replace
| From: | tripman at clubbing dot pl | Date: | Wed, 14 May 2003 14:15:57 +0000 |
| Subject: | note 32039 added to function.preg-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-47958@lists.php.net to get a copy of this message | ||
Once again, a bugfixed release of the mailto-link-maker.
jomango's version treats ftp://login:pass@111.222.333.44/ as an emial address
what is obviously wrong.
my function looks like this:
function makeLinks($text)
{
$search = array("/(?<!quot;|[=\"]|:\/{2})\b((\w+:\/{2}|www\.).+?)"."
(?=\W*([<>\s]|$))/i", "/\b(^| )([\w\.]+)(@)([\w\.-]+)\b/i");
$replace = array("<a href=\"$1\">$1</a>", "<a
href=\"mailto:$0\">$0</a>");
return preg_replace("/href=\"www/i", "href=\"http://www", preg_replace ($search, $replace, $text));
}
Cheers, Rail
--
http://www.php.net/manual/en/function.preg-replace.php
http://master.php.net/manage/user-notes.php?action=edit+32039
http://master.php.net/manage/user-notes.php?action=delete+32039
http://master.php.net/manage/user-notes.php?action=reject+32039