note 51786 added to function.preg-replace
| From: | anders dot carlsson at sfks dot se | Date: | Mon, 11 Apr 2005 11:05:02 +0000 |
| Subject: | note 51786 added to function.preg-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-87822@lists.php.net to get a copy of this message | ||
Regarding turning an e-mail address into a mailto-link or similar, one should not forget that not
all e-mail addresses follow the pattern x@y.z but sometimes x@w.y.z or even x@u.w.y.z. Thus I'm
using a pattern like this:
/(\\S+@\\S+\\.\\w+)/
which supposedly matches a row of non-whitespace characters (incl. punctuation, numbers etc),
followed by @, another row of non-whitespace characters (including dots), at least one dot and then
end with a series of "word" characters, i.e. letters. To my knowledge there is no top
domain that ends with something else than a letter, maybe with the exception of foreign writing
systems, but even e.g. China and Japan use .cn and .jp respectively in the end?
I suppose the pattern could be split into two or more parts, e.g. if one wants to display despammed
addresses. The pattern however would not work for top domains accepting email, like john.doe@com
(which probably is not so common anyway).
----
Manual Page -- http://www.php.net/manual/en/function.preg-replace.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+51786
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+51786&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+51786&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+51786&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+51786&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+51786&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+51786&report=yes
Search -- http://master.php.net/manage/user-notes.php