You are here: Re: [PHP] Re: Email Validation built-in? RFC « PHP « IT news, forums, messages
Re: [PHP] Re: Email Validation built-in? RFC

Posted by Robin Vickery on 10/24/05 00:21

On 10/23/05, Manuel Lemos <mlemos@acm.org> wrote:
> Hello,
>
>
> on 10/22/2005 12:58 AM Richard Lynch said the following:
> > Checking MX records is not reliable at all.
>
> I agree that it is less useful today, but it still help catches many
> domain name typos.
>
>
> > ... would it not make sense for there to be a BUILT-IN PHP function of
> > a TRUE email syntactic validation?
>
> I don't see that being much better than passing a good regular
> expression to preg_match.

1. Technically you can't write a regular expression that matches
*all* valid email addresses as part of the address specification is
recursive.

ccontent = ctext / quoted-pair / comment
comment = "(" *([FWS] ccontent) [FWS] ")"

Admittedly 99.99% of people don't even know you *can* comment email
addresses so it's not a huge problem...

2. Very few people seem to be capable of recognising a *good* regular
expression, let alone writing one. It seems clear that validating an
address is a task that many people want to do, but few can do
properly. I'd say that's a good reason for making it a built-in
function.

>
> For many years I use this regular expression in popular email validation
> and forms generation and validation classes.
>
>
> Rather than accepting only valid characters, it rejects all invalid
> characters as specified in the RFC.
>
> ^([-!#$%&'*+./0-9=?A-Z^_`a-z{|}~])+@([-!#$%&'*+/0-9=?A-Z^_`a-z{|}~]+\\.)+[a-zA-Z]{2,6}$
>

I'm sorry, but this regular expression rejects many perfectly valid
ASCII characters. It seems to take into account only dot-atoms, not
quoted-strings. It also rejects valid addresses using domain-literals.

-robin

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация