Live data from Hacker News

Perfect email regex finally found

fightingforalostcause.net

91–100 of 118 posts

Re: Perfect email regex finally found

#91
post #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.

In which you are assuming you will receive a proper bounce, which is not warranted. Checking bounces is something you can do in addition to checking whether the user didn't screw up his email address.

Re: Perfect email regex finally found

#92
post #28

Earlier quoted context omitted.

Along those lines, I've settled on the following overly permissive regex: /^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/ -- it makes sure it looks something like an email address (a@b.cd)

What if my email address is: "@"@example.com ?

Then you should be taken outside and shot as you probably set it up yourself. ;)

Re: Perfect email regex finally found

#93
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 - confus…

The have a lot more problems to deal with if they have to deal with all the people that include a stray space in the address.

There are regexes out there that catch all valid addresses that people reasonably use (including those with dashes and ending in .us) and the fact that all kinds of incompetent developers use a homebrewn regex is no reason to lower the best case scenario to "just don't validate". Just do it right.

Re: Perfect email regex finally found

#94

How in the world did this get 172 points? After this I almost stopped paying attention: "It's my philosophy that it's better to accept a few invalid addresses than reject any valid ones, so I'm shooting for 0 false-positives and as few false-negatives as possible." But then I looked at the regexps and they miss an absolutely trivial fact: valid email addresses can end in a dot. "jemfinch@supybot.com." is just as vali…

>How in the world did this get 172 points?

Things don't have to be well done, nor do you have to agree with them for them to be worth consideration/stimulating.

Re: Perfect email regex finally found

#95
post #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.

So what happens when a mailserver uses greylisting to filter spam ?

Re: Perfect email regex finally found

#96
Wow.

  /^[-a-z0-9~!$%^&*_=+}{\'?]+(\.[-a-z0-9~!$%^&*_=+}{\'?
  ]+)*@([a-z0-9_][-a-z0-9_]*(\.[-a-z0-9_]+)*\.(aero|arpa|
  biz|com|coop|edu|gov|info|int|mil|museum|name|net|org|
  pro|travel|mobi|[a-z][a-z])|([0-9]{1,3}\.[0-9]{1,3}\.
  [0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,5})?$/i
I mean... Why do this? Just, why? It's almost unreadable.

Just write a short 20-line function which validates an email address. Use if statements. Write comments. Then verify that your algorithm does in fact handle all corner cases, just like the regexp does. (Your verifications will be in the form of short, simple unit test case functions.)

To encourage regexp abuse like that is to encourage bad programming.

Re: Perfect email regex finally found

#98
I think a basic token based parser might be more appropriate for thorough validation of email addresses. I see it similar to trying to match XML or HTML with regexps, very common but so very easy to break. You can't go to wrong parsing an address token by token, can you?

Re: Perfect email regex finally found

#99
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…

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. Well, I hope you have a large enough support team, because with any reasonable amount of customer growth, you'll soon be swamped with support emails that say "I didn't get my ..., where is it? You suck!". Validating the email ad…

Even if they've typed it correctly it still can be blocked for various reasons.

You will still need a support mechanism (doesn't have to get all the way to a person) to sort out undelivered verification mails. It's just how it goes.

Post reply on HN