Email address regular expression

This is a discussion on Email address regular expression within the PHP Language forums, part of the PHP Programming Forums category; Craig Bailey <ccb@floydianslip.com> wrote in message news:<ccb-CE3EE0.06162706102003@news.verizon.net>... > ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #11 (permalink)  
Old 10-06-2003
Lothar Scholz
 
Posts: n/a
Default Re: Email address regular expression - Never use them

Craig Bailey <ccb@floydianslip.com> wrote in message news:<ccb-CE3EE0.06162706102003@news.verizon.net>...
> I've been using this pattern to verify email addresses:
>
> ^([0-9a-z]+)([0-9a-z\.-_]+)@([0-9a-z\.-_]+)\.([0-9a-z]+)
>
> But I've recently discovered that addresses with a dash in them won't
> pass this test.
>
> Seems to me they should pass.
>
> What's wrong?


In the book "Mastering Regular Expressions" there is an approximation
for internet email addresses, emails are to complex to be handed by
regular expressions correctly.

This regular expression is about 4800 characters long.

The best way is to not check any email addresses. Maybe assuming that
there must be a '@' is the only thing. Escpecially now where UTF can
be used in domain names, every [a-z] kind of pattern is simply wrong.
Reply With Quote
  #12 (permalink)  
Old 10-07-2003
William Maddler
 
Posts: n/a
Default Re: Email address regular expression - Never use them

Lothar Scholz wrote:

> In the book "Mastering Regular Expressions" there is an approximation
> for internet email addresses, emails are to complex to be handed by
> regular expressions correctly.


I agree...
usually what I check is to have smth before the @ and at least a word after
and that the mail address ends with a valid TLD...

--
WM
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 06:36 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0