471,074 Members | 1,444 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,074 software developers and data experts.

Email RegularExpression not working

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

us**@blah.ru

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?


Nov 17 '05 #1
4 1179
try validationExpression="\S+@\S+\.\S{2,3}"

"Learning SQL Server" <no.mail.com> wrote in message
news:ue*************@TK2MSFTNGP10.phx.gbl...
The email reg exp that ships with the RegularExpressionValidator doesnt like this email address:

us**@blah.ru

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?

Nov 17 '05 #2
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" <no.mail.com> wrote in message
news:ue*************@TK2MSFTNGP10.phx.gbl...
The email reg exp that ships with the RegularExpressionValidator doesnt like this email address:

us**@blah.ru

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?

Nov 17 '05 #3
Colin:
I was looking at another expression *sheepish grin*
"Colin Young" <x@nospam.com> wrote in message
news:Oq*************@TK2MSFTNGP10.phx.gbl...
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" <no.mail.com> wrote in message
news:ue*************@TK2MSFTNGP10.phx.gbl...
The email reg exp that ships with the RegularExpressionValidator doesnt

like
this email address:

us**@blah.ru

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?


Nov 17 '05 #4
"Learning SQL Server" <no.mail.com> wrote in
news:ue*************@TK2MSFTNGP10.phx.gbl:
The email reg exp that ships with the RegularExpressionValidator
doesnt like this email address:

us**@blah.ru

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|mu seum|coop|aero|pr
o|[a-zA-Z]{2})$
Hope this helps.

Chris.
-------------
C.R. Timmons Consulting, Inc.
http://www.crtimmonsinc.com/
Nov 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by fabrice | last post: by
1 post views Thread by Nicola Farina | last post: by
2 posts views Thread by Fabio | last post: by
3 posts views Thread by Arpan | last post: by
1 post views Thread by Arpan | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.