Re: Regex validation

From: Date: Thu, 30 Oct 2008 17:24:10 +0000
Subject: Re: Regex validation
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-282639@lists.php.net to get a copy of this message
ceo wrote: >var_dump(imap_rfc822_parse_adrlist('"! # $ % & * + - / = ? ^ _ ` { | } >~"', '')); >This looks like a valid localhost email address to me... It surely is a valid localhost email address, but what most people (and the OP) usually need is to validate a full email string with a local and a domain part. What should be valid email addresses according to RFC 2822 [1]: !#$%&*+-/=?^_`{|}~@example.com "@"@example.com Not valid email addresses: "\"@example.com @@example.com - -@example.com Valid email addresses according to the Multipurpose Internet Mail Extension (MIME) [2]: ä@example.com é@℞.com So for people who got to write code that also works on PHP4 it is not very easy to validate an email address. Even nice regex attempts like [3] fail since more and more mail servers support the MIME hieroglyphs. That's why I was pretty excited about imap_rfc822_parse_adrlist(), since it runs in PHP4 if installed. Which clearly is no substitute for the PHP5+ filter functions [4]. If it's just my brain farting and there actually then tell me. [1] http://www.faqs.org/rfcs/rfc2822.html [2] http://en.wikipedia.org/wiki/MIME [3] http://www.addedbytes.com/php/email-address-validation/ [4] http://in.php.net/filter

« previous php.general (#282639) next »