note 43540 rejected from function.preg-match by aidan
| From: | aidan@php.net | Date: | Sun, 04 Jul 2004 16:21:08 +0000 |
| Subject: | note 43540 rejected from function.preg-match by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-72525@lists.php.net to get a copy of this message | ||
Note Submitter: Zach Johnson
----
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