One of my colleagues asked a question that I’ve heard dozens of times over my career…
What’s a good regular expression for validating email addresses.
Sadly, due to poor standards, poor implementation choices, and just the sheer age of Email, this is a surprisingly tough problem.
The best way to validate an email address is to email it, and get the user to do something. That’s not really feasible if it’s someone just filling in a form.
Failing that, I came up with:
^[^@\s]+@[^@\s]+\.[^@\s]+$
This is the same as suggested by Microsoft, which is gratifying. You can see the logic of it here.