I recently read somewhere that writing a regexp to match an email address, taking into account all the variations and possibilities of the standard is extremely hard and is significantly more complicated than what one would initially assume.
Why is that?
Are there any known and proven regexps that actually do this fully?
What are some good alternatives to using regexps for matching email addresses?
For the formal e-mail spec, yes, it is technically impossible via Regex due to the recursion of things like comments (especially if you don’t remove comments to whitespace first), and the various different formats (an e-mail address isn’t always someone@somewhere.tld). You can get close (with some massive and incomprehensible Regex patterns), but a far better way of checking an e-mail is to do the very familiar handshake:
when they click on the link you know that:
Far better than blindly accepting an e-mail address.