note 43540 added to function.preg-match
| From: | ZachJohnson at rn2 dot php dot net | Date: | Thu, 24 Jun 2004 21:08:38 +0000 |
| Subject: | note 43540 added to function.preg-match | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-71617@lists.php.net to get a copy of this message | ||
I'm confused about the point made by "thhof at freenet dot de."
My expression will accept an email address such as name@domain.co.uk as will his expression.
However, his expression also accepts those in the form of name@.domain.com which is NOT valid. (No
leading dot's.)
If we want to get really technical, the following is every better than what I posted before:
preg_match( "/^[-^!#$%&'*+\/=?`{|}~.\w]+@" .
"[a-zA-Z0-9]([-a-zA-Z0-9]*[a-zA-Z0-9])*" .
"(\.[a-zA-Z0-9]([-a-zA-Z0-9]*[a-zA-Z0-9])*)+$/", $email )
This allows for name@my-subdomain.my-domain.com but does not allow for name@-mydomain-.com. (No
leading or trailing dash's.) If you'd like, you could change my expression to force it to
end with 2-6 LETTERS only, but who knows what TLD's they will come up with in the future.
cheers,
Zach
----
Manual Page -- http://www.php.net/manual/en/function.preg-match.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+43540
Delete -- http://master.php.net/manage/user-notes.php?action=delete+43540&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+43540&report=yes
Search -- http://master.php.net/manage/user-notes.php