-- Leo's gemini proxy

-- Connecting to freeshell.de:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini;lang=en-GB

Re: Validate email address using Regex in C++

Martin at clehaxze.tw wanted to validate email addresses with regex

I get on a high horse

This is well known to be impossible. The site that Martin links to claims 99.99% accuracy. Does that mean that for every billion addresses there's 10 million that don't match the regex!? I bet there are quite a few billion email addresses.


And it's not impossible just for regex reasons. Some addresses that work are invalid according to the RFC. Some addresses will be valid but not work. The way to validate an address is just to send email because it has to be handled correctly by whatever buggy mail software it passes through.


As an example, when a mail provider I used changed software, mail to jbanana+tag@example.com stopped arriving because of the tag part. It was still valid, but so what?


I ponder motivation

Enough moaning! What's the use case for validating an email address? I typo my address: jbanana@examplecom (oops, no dot). It would be helpful to point that out to me. OK, I'll try again: jbanana@example.con (I meant .com) and now the regex says it's ok, but I never get any mail.


I try to draw a conclusion, but end up moaning again

You can't win here. The best that you can do is suggest to someone that their address *might* be wrong, but if they insist it's correct, believe them, but send mail to confirm.


One of my pet hates is web forms that try to prevent you pasting your address. I'm pasting so I know that I didn't typo it, FFS!


OK, that (I'm sure you'll agree) is enough.


#email

#EmailAddress


back to gemlog

-- Response ended

-- Page fetched on Sat May 4 01:22:36 2024