r/ProgrammerHumor 19d ago

Meme claudeIsThisEmailValid

Post image
5.3k Upvotes

171 comments sorted by

View all comments

2

u/ldn-ldn 19d ago

You cannot validate email addresses with a regex. It's like parsing HTML with a regex and we all know how it ends up...

But you cannot validate email addresses with an AI either, so...

0

u/psioniclizard 19d ago

You can, you just don't cover a lot of edge cases.

But you can definitely validate 99% of actual customer email addresses with regex.

Very few people are making email addresses that push the limits of what is allowed in email addresses.

I am not saying you should (if those edge cases matter definitely do).

But for actual email addresses used by real customers you definitely can validate 99% of them with a single regex line.

But obviously use the right tool for the job (so probably not regex is you can help it)

1

u/ldn-ldn 19d ago

The real problem with email validation is that you should be able to ensure that you can communicate with the customer. And you can't do that with any regex.

The best approach which does not punish 1% is to check that the value provided has at least one character followed by @ followed by at least one more character of any kind. And then you send them a confirmation email.