Built-in RegularExpressionValidator email regex

G

Guest

I was just wondering if there is a reason (maybe a RFC requirement?) that the
built in email address regular expression for the RegularExpressionValidator
in ASP.NET doesn't support email aliases ending in a dash.

For example, the following address will not validate:
(e-mail address removed)

Thanks,

-Steven
 
K

Karl Seguin

Steven,
If you are familiar with RFC's, why not just look it up? :) my typically
answer to this would be to look up the RFC..teach a man how to fish
afterall..

Anyways, I'd still try to help since RFCs are a pain in the rear and I just
spent 10 minutes trying to follow it because I wanted to know as well.

RFC 2822..
addr-spec = local-part "@" domain
so we are interested in local-part

local-part = dot-atom / quoted-string / obs-local-part
we'll look at dot-atom since that's the most common and we don't want to
quote our email adrress

dot-atom = [CFWS] dot-atom-text [CFWS]
ignore the CFWS (folding whitespace w/comments), so we want the
dot-atom-text

dot-atom-text = 1*atext *("." 1*atext)
so we want atext

atext = ALPHA / DIGIT / ; Any character except controls,
"!" / "#" / ; SP, and specials.
"$" / "%" / ; Used for atoms
"&" / "'" /
"*" / "+" /
"-" / "/" /
"=" / "?" /
"^" / "_" /
"`" / "{" /
"|" / "}" /
"~"
note that dash isn't in the list, but maybe it's under ALPHA

item-name = ALPHA *(["-"] (ALPHA / DIGIT))
BINGO! We have a dash, but if you have a dash, it must clearly be followed
by another ALPHA or Digit

I could have followed that wrong (and there certainly are other paths) but I
think it's right.

hope that hels ;)

Karl
 
S

Steven Berkovitz

Karl,

Thanks for taking the time to explain this.

I guess my next question is (not for you), why is hotmail allowing this?


Karl Seguin said:
Steven,
If you are familiar with RFC's, why not just look it up? :) my typically
answer to this would be to look up the RFC..teach a man how to fish
afterall..

Anyways, I'd still try to help since RFCs are a pain in the rear and I
just spent 10 minutes trying to follow it because I wanted to know as
well.

RFC 2822..
addr-spec = local-part "@" domain
so we are interested in local-part

local-part = dot-atom / quoted-string / obs-local-part
we'll look at dot-atom since that's the most common and we don't want to
quote our email adrress

dot-atom = [CFWS] dot-atom-text [CFWS]
ignore the CFWS (folding whitespace w/comments), so we want the
dot-atom-text

dot-atom-text = 1*atext *("." 1*atext)
so we want atext

atext = ALPHA / DIGIT / ; Any character except controls,
"!" / "#" / ; SP, and specials.
"$" / "%" / ; Used for atoms
"&" / "'" /
"*" / "+" /
"-" / "/" /
"=" / "?" /
"^" / "_" /
"`" / "{" /
"|" / "}" /
"~"
note that dash isn't in the list, but maybe it's under ALPHA

item-name = ALPHA *(["-"] (ALPHA / DIGIT))
BINGO! We have a dash, but if you have a dash, it must clearly be
followed by another ALPHA or Digit

I could have followed that wrong (and there certainly are other paths) but
I think it's right.

hope that hels ;)

Karl



--
MY ASP.Net tutorials
http://www.openmymind.net/
Steven Berkovitz said:
I was just wondering if there is a reason (maybe a RFC requirement?) that
the
built in email address regular expression for the
RegularExpressionValidator
in ASP.NET doesn't support email aliases ending in a dash.

For example, the following address will not validate:
(e-mail address removed)

Thanks,

-Steven
 
K

Karl Seguin

Well, there is a quoted-string variant to the dot-atom path we explored.
Reading the specs, it's my belief that quoted-string would allow for a
local-addr to be terminated with a - if it's quoted, ala "test-address-"
(with the quotes actually there).


qtext = NO-WS-CTL / ; Non white space controls

%d33 / ; The rest of the US-ASCII
%d35-91 / ; characters not including "\"
%d93-126 ; or the quote character

qcontent = qtext / quoted-pair

quoted-string = [CFWS]
DQUOTE *([FWS] qcontent) [FWS] DQUOTE
[CFWS]a dash is decimal 45, so it falls in the
%d35-91Perhaps that's what hotmail does.Karl-- MY ASP.Net
tutorialshttp://www.openmymind.net/"Steven Berkovitz"
Karl,

Thanks for taking the time to explain this.

I guess my next question is (not for you), why is hotmail allowing this?


Karl Seguin said:
Steven,
If you are familiar with RFC's, why not just look it up? :) my typically
answer to this would be to look up the RFC..teach a man how to fish
afterall..

Anyways, I'd still try to help since RFCs are a pain in the rear and I
just spent 10 minutes trying to follow it because I wanted to know as
well.

RFC 2822..
addr-spec = local-part "@" domain
so we are interested in local-part

local-part = dot-atom / quoted-string / obs-local-part
we'll look at dot-atom since that's the most common and we don't want to
quote our email adrress

dot-atom = [CFWS] dot-atom-text [CFWS]
ignore the CFWS (folding whitespace w/comments), so we want the
dot-atom-text

dot-atom-text = 1*atext *("." 1*atext)
so we want atext

atext = ALPHA / DIGIT / ; Any character except controls,
"!" / "#" / ; SP, and specials.
"$" / "%" / ; Used for atoms
"&" / "'" /
"*" / "+" /
"-" / "/" /
"=" / "?" /
"^" / "_" /
"`" / "{" /
"|" / "}" /
"~"
note that dash isn't in the list, but maybe it's under ALPHA

item-name = ALPHA *(["-"] (ALPHA / DIGIT))
BINGO! We have a dash, but if you have a dash, it must clearly be
followed by another ALPHA or Digit

I could have followed that wrong (and there certainly are other paths)
but I think it's right.

hope that hels ;)

Karl



--
MY ASP.Net tutorials
http://www.openmymind.net/
Steven Berkovitz said:
I was just wondering if there is a reason (maybe a RFC requirement?) that
the
built in email address regular expression for the
RegularExpressionValidator
in ASP.NET doesn't support email aliases ending in a dash.

For example, the following address will not validate:
(e-mail address removed)

Thanks,

-Steven
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,608
Members
45,249
Latest member
KattieCort

Latest Threads

Top