Email RegularExpression not working

  • Thread starter Thread starter Learning SQL Server
  • Start date Start date
L

Learning SQL Server

The email reg exp that ships with the RegularExpressionValidator doesnt like
this email address:

(e-mail address removed)

Or any other email domain that contains only 2 letters after the dot.

It *looks* like it should (I notice the qualifier at the end of the
statement for 2 or more letters), but the validator always fires anyway.
Anyone else notice similar behavior or do I just need some sleep?
 
This is the one I use:

[\w-.]+?@([\w-]+?\.)+[\w]{2,}

I've tested it fairly extensively, including a couple of embarassing
incidents where potential customers trying to register emailed me to tell me
that my form wouldn't accept their email address, resulting in the included
regular expression.

I haven't had any emails for a while now to tell me I'm rejecting valid
addresses.

Colin
 
Colin:
I was looking at another expression *sheepish grin*


Colin Young said:
This is the one I use:

[\w-.]+?@([\w-]+?\.)+[\w]{2,}

I've tested it fairly extensively, including a couple of embarassing
incidents where potential customers trying to register emailed me to tell me
that my form wouldn't accept their email address, resulting in the included
regular expression.

I haven't had any emails for a while now to tell me I'm rejecting valid
addresses.

Colin

Learning SQL Server said:
The email reg exp that ships with the RegularExpressionValidator doesnt like
this email address:

(e-mail address removed)

Or any other email domain that contains only 2 letters after the dot.

It *looks* like it should (I notice the qualifier at the end of the
statement for 2 or more letters), but the validator always fires anyway.
Anyone else notice similar behavior or do I just need some sleep?
 
The email reg exp that ships with the RegularExpressionValidator
doesnt like this email address:

(e-mail address removed)

Or any other email domain that contains only 2 letters after the
dot.

It *looks* like it should (I notice the qualifier at the end of
the statement for 2 or more letters), but the validator always
fires anyway. Anyone else notice similar behavior or do I just
need some sleep?

Here's a regex I use to validate e-mail addresses:

^[-a-zA-Z0-9][-.a-zA-Z0-9]*@[-.a-zA-Z0-9]+(\.[-.a-zA-Z0-
9]+)*\.(com|edu|info|gov|int|mil|net|org|biz|name|museum|coop|aero|pr
o|[a-zA-Z]{2})$


Hope this helps.

Chris.
 
Back
Top