note 16055 added to function.ereg-replace
| From: | simonATobscureD0TcoD0Tnz at php2 dot chek dot com | Date: | Mon, 15 Oct 2001 07:13:46 +0000 |
| Subject: | note 16055 added to function.ereg-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-18916@lists.php.net to get a copy of this message | ||
The above link functions affect existing urls inside html thats already in the string, this leaves
existing urls (eg in an IMG tag) untouched
function node_parse_text ( $text ) {
$text = ereg_replace("((www.)([a-zA-Z0-9@:%_.~#-\?&]+[a-zA-Z0-9@:%_~#\?&/]))",
"http://\\1", $text);
$text = ereg_replace("((ftp://|http://|https://){2})([a-zA-Z0-9@:%_.~#-\?&]+[a-zA-Z0-9@:%_~#\?&/])",
"http://\\3", $text);
$text = ereg_replace("(((ftp://|http://|https://){1})[a-zA-Z0-9@:%_.~#-\?&]+[a-zA-Z0-9@:%_~#\?&/])",
"<a href=\"\\1\">\\1</a>", $text);
$text = ereg_replace("((<a href=\"<a href=\")(((ftp://|http://|https://){1})[a-zA-Z0-9@:%_.~#-\?&]+[a-zA-Z0-9@:%_~#\?&/]\">))((((ftp://|http://|https://)([a-zA-Z0-9@:%_.~#-\?&]+[a-zA-Z0-9@:%_~#\?&/]))))(</a>\">)",
"<a href=\"\\6\">", $text);
$text = ereg_replace("([_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3})","<a
href=\"mailto:\\1\">\\1</a>", $text);
return $text;
}
--
http://www.php.net/manual/en/function.ereg-replace.php
http://master.php.net/manage/user-notes.php?action=edit+16055
http://master.php.net/manage/user-notes.php?action=delete+16055
http://master.php.net/manage/user-notes.php?action=reject+16055