Almost every codebase I've touched has some version of this line:

const ok = /^[^@]+@[^@]+\.[^@]+$/.test(email);

Enter fullscreen mode

Exit fullscreen mode

It feels like email validation. It isn't. Here's what that regex actually misses, and a more honest way to check an address before you trust it.