Click here to Skip to main content
15,915,600 members
Home / Discussions / Web Development
   

Web Development

 
GeneralWell, solved the "problem" in a way... Pin
Peter, The Pumpkin Eater12-Dec-03 1:40
Peter, The Pumpkin Eater12-Dec-03 1:40 
QuestionHow do I ... Pin
Aryo Handono11-Dec-03 1:47
professionalAryo Handono11-Dec-03 1:47 
AnswerRe: How do I ... Pin
Nathan Ridley11-Dec-03 2:22
Nathan Ridley11-Dec-03 2:22 
GeneralRe: How do I ... Pin
Aryo Handono11-Dec-03 2:25
professionalAryo Handono11-Dec-03 2:25 
QuestionWhat is the difference between .asp, .htm, .html? Pin
DanYELL10-Dec-03 7:49
DanYELL10-Dec-03 7:49 
AnswerRe: What is the difference between .asp, .htm, .html? Pin
ZoogieZork10-Dec-03 9:15
ZoogieZork10-Dec-03 9:15 
AnswerRe: What is the difference between .asp, .htm, .html? Pin
Nathan Ridley10-Dec-03 17:30
Nathan Ridley10-Dec-03 17:30 
GeneralRegular Expression e-mail verification Pin
10-Dec-03 5:34
suss10-Dec-03 5:34 
Hi there!

I'm most certain this topic has been discussed previously hundreds of times, yet I have a little problem with this which probably deserves a new thread:

I built a few days ago a regular expression email verification (actually copy-pasted it from some place I can't remember now :-P) to be used to filter email input in a web-page I'm working on.
Yesterday my boss called very angry because one of his clients wasn't able to enter his email. Obviously the client's email was a valid one and my function was rejecting it, so I have to correcti it. The problem was my regexp wasn't allowing the address to start with a digit (doh!):

^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$

Ok, solving this is most easy, but my boss was so damn angry, he told me to be absolutely sure all valid email addresses will be accepted when I fix it... so I made my homework... I ran into RFC2821 and RFC821 to check out SMTP rules, and found something weird:

According to RFC821 (http://www.faqs.org/rfcs/rfc821.html), the syntax for the email address is as follows (check the original RFC821 for a complete explanation, I'm filtering out a lot of stuff here):

<mailbox> ::= <local-part> "@" <domain>
<local-part> ::= <dot-string> | <quoted-string>
<dot-string> ::= <string> | <string> "." <dot-string>
<string> ::= <char> | <char> <string>
<char> ::= <c> | "\" <x>
<c> ::= any one of the 128 ASCII characters, but not any <special> or <SP>
<x> ::= any one of the 128 ASCII characters (no exceptions)
<SP> ::= the space character (ASCII code 32)
<special> ::= "<" | ">" | "(" | ")" | "[" | "]" | "\" | "." | "," | ";" | ":" | "@" """ | the control characters (ASCII codes 0 through 31 inclusive and 127)


The logic to understand the previous is rather simple: <mailbox> is composed of <local-part> AND "@" AND <domain>. Then <local-part> is composed of <dot-string> OR <quoted-string>, and so on. I left <quoted-string> and <domain> out of this because the quoted-string is a more complex notation for the same thing, and domain suffers of the same problem I'll explain now:

If you check the ASCII table, and filter out the INVALID characters according to the previous rules (not taking in count that quoting a char with backslash -i.e. \% - allows to enter ANY character), the valid set of characters for an email address is (values in parenthesis are ASCII codes):

letters: a - z AND A - Z
digits : 0 - 9
extras : ! (33), # (35), $ (36), % (37), & (38), ' (39), * (42), + (43), - (45), / (47), = (61), ? (63), \ (92), ^ (94), _ (95), { (123), | (124), } (125), ~ (126)

Now let's review this: letters, no problem... digits, no problem... but hey!!... what happened with the extra symbols?? I'm not complaining about 45, 95 (which are very common in email addresses) but the remaining are ALSO VALID?? Could this be possible?

Now, I can build a regexp to accept all this "extra" symbols, but my question here is ARE THEY ACTUALLY VALID? most of all ARE THEY VALID ANYWHERE IN THE SYNTAX?

I hope someone has the patience to read all this and give any comments about this.

Bundy
GeneralRe: Regular Expression e-mail verification Pin
Daniel Turini10-Dec-03 6:21
Daniel Turini10-Dec-03 6:21 
GeneralRe: Regular Expression e-mail verification Pin
ZoogieZork10-Dec-03 6:28
ZoogieZork10-Dec-03 6:28 
GeneralRe: Regular Expression e-mail verification Pin
Member 70965910-Dec-03 8:03
Member 70965910-Dec-03 8:03 
GeneralButton development Pin
Rafael Fernández López9-Dec-03 8:27
Rafael Fernández López9-Dec-03 8:27 
GeneralWebService and Dataset Pin
sybux20009-Dec-03 5:57
sybux20009-Dec-03 5:57 
GeneralRe: WebService and Dataset Pin
susree11-Dec-03 21:55
susree11-Dec-03 21:55 
GeneralProblem while populating data in Microsoft Treeview control Pin
Sunil. K9-Dec-03 1:05
Sunil. K9-Dec-03 1:05 
QuestionFrontPage Server Extensions- 2000 or 2002? Pin
ThomasH17-Dec-03 16:26
ThomasH17-Dec-03 16:26 
AnswerRe: FrontPage Server Extensions- 2000 or 2002? Pin
Roger Wright7-Dec-03 21:26
professionalRoger Wright7-Dec-03 21:26 
GeneralRe: FrontPage Server Extensions- 2000 or 2002? Pin
ThomasH18-Dec-03 3:57
ThomasH18-Dec-03 3:57 
GeneralRe: FrontPage Server Extensions- 2000 or 2002? Pin
Roger Wright8-Dec-03 5:14
professionalRoger Wright8-Dec-03 5:14 
GeneralRe: FrontPage Server Extensions- 2000 or 2002? Pin
ThomasH18-Dec-03 7:12
ThomasH18-Dec-03 7:12 
GeneralRe: FrontPage Server Extensions- 2000 or 2002? Pin
Roger Wright8-Dec-03 8:33
professionalRoger Wright8-Dec-03 8:33 
GeneralRe: FrontPage Server Extensions- 2000 or 2002? Pin
ThomasH18-Dec-03 14:15
ThomasH18-Dec-03 14:15 
GeneralRe: FrontPage Server Extensions- 2000 or 2002? Pin
ThomasH19-Dec-03 4:53
ThomasH19-Dec-03 4:53 
GeneralRe: FrontPage Server Extensions- 2000 or 2002? Pin
Roger Wright9-Dec-03 7:35
professionalRoger Wright9-Dec-03 7:35 
GeneralEmail server side question Pin
alex.barylski7-Dec-03 9:24
alex.barylski7-Dec-03 9:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.