note 53567 added to function.preg-match
| From: | hackajar<matt>yahoo" com | Date: | Mon, 06 Jun 2005 09:12:39 +0000 |
| Subject: | note 53567 added to function.preg-match | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-89997@lists.php.net to get a copy of this message | ||
In regards to Stony666 email validator:
Per RFC 1035, domain names must be combination of letter, numbers and hyphens. _ and % are not
allowed. They should be no less the 2 and no greater then 63 characters. Hypens may not appear at
begging or end.
Per RFC 822, email address- when regarding username - % generally not accepted in "new"
(ha 1982 'new') format. _ and - are OK (as well as "." but not in subdomain but
rather "real" username)
here's something a little better:
if(preg_match('/^[A-Z0-9._-]+@[A-Z0-9.-]+\.[A-Z]{2,6}$/i', $data)) return true;
Small problem with this thought, I can't wrap my mind around the limit domain name to 2-63
characters, nor how to check for hypens at begging and end. Maybe someone else can toss in a better
revision?
----
Manual Page -- http://www.php.net/manual/en/function.preg-match.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+53567
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+53567&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+53567&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+53567&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+53567&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+53567&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+53567&report=yes
Search -- http://master.php.net/manage/user-notes.php