note 53567 deleted from function.preg-match by colder

From: Date: Mon, 18 Jun 2007 18:22:37 +0000
Subject: note 53567 deleted from function.preg-match by colder
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-127601@lists.php.net to get a copy of this message
Note Submitter: hackajar <matt> yahoo <trot> com ---- 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?

« previous php.notes (#127601) next »