Live data from Hacker News

Perfect email regex finally found

fightingforalostcause.net

31–40 of 118 posts

Re: Perfect email regex finally found

#31
Uh, what happens if a new TLD has more than 6 characters?

I don't get this preoccupation with making sure addresses look valid. The ONLY way to validate an email address is to send it a message.

Re: Perfect email regex finally found

#33
post #2

How ugly do non-regex based email validation functions look? I've never seen one, but I've always wondered if that was a more elegant solution.

One nice looking trick I've seen is checking the domain of the email address for an MX record. (e.g. http://php.dzone.com/news/php-email-validator-email-mx-d ) Possibly this approach is too slow to use by itself without a regex. Also maybe there are other problems with this method I'm not aware of?

[deleted]

Re: Perfect email regex finally found

#35
post #26

Earlier quoted context omitted.

Especially when the spec itself is in EBNF.

True, though it's EBNF with a bunch of explanatory text and annotations. What would be interesting, but I can't find with some googling: Has someone implemented a parser-generator based on the spec? The ideal would be that the parser specification looks a lot like the RFC, since then you'd have more confidence it was actually correct (and it'd be easier to maintain for future changes).

My comment above is a regex derived straightforwardly from the spec. Not a full parser, though.

Re: Perfect email regex finally found

#37
post #14

I've accepted that it's best to treat people like grown-ups and if there's '@' and '.' and it's retyped then it passes. Someone can easily submit a fake name or phone number or street address, and e-mail's no different. If they get it wrong, intentionally or not, then they don't get their receipt, confirmation, validation link, etc. and I believe in most cases the incentive is there for them to get it right. In the r…

Retyped!? Grown-ups can read what they write.

Retyping only makes sense for password field, which is obfuscated and doesn't allow copy&paste.

Re: Perfect email regex finally found

#38
So many web services do this wrong, that it isn't even worth doing it right: no one is going to complain that your service doesn't accept their "wacky! quoted"@email.address

Sometimes, you aren't validating a whole string, you are searching for email addresses in a sea of text, or an arbitrarily delimited, user-entered list of contacts.

Support usernames with alphanumerics, dashes, underscores, periods, and plus signs; Require a single @; Support domains with alphanumerics, dashes, and at least one period. Screw anyone with something more complex than that. Done deal.

Re: Perfect email regex finally found

#39
post #14

I've accepted that it's best to treat people like grown-ups and if there's '@' and '.' and it's retyped then it passes. Someone can easily submit a fake name or phone number or street address, and e-mail's no different. If they get it wrong, intentionally or not, then they don't get their receipt, confirmation, validation link, etc. and I believe in most cases the incentive is there for them to get it right. In the r…

I also do simple email verification:

1) Send an email to the address.

2) If it succeeds, the address was valid.

Re: Perfect email regex finally found

#40
post #14

I've accepted that it's best to treat people like grown-ups and if there's '@' and '.' and it's retyped then it passes. Someone can easily submit a fake name or phone number or street address, and e-mail's no different. If they get it wrong, intentionally or not, then they don't get their receipt, confirmation, validation link, etc. and I believe in most cases the incentive is there for them to get it right. In the r…

My thoughts exactly. There are so many websites that tell me my valid email address is invalid that it's not even funny. These people then have to deal with phonecalls and lost business, because their form won't even submit without a valid email address (and why should I change if they're the ones that suck).

BTW, the email address that doesn't work is "jon-whatever@jrock.us". The .us confuses people and the - confuses people. WTF!?

Post reply on HN