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>... > ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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. |
|
|||
|
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 |