The 99% pattern
Real email regex (RFC 5322 compliant) is over 6,000 characters and includes nested comments, quoted strings, IP literals, and Unicode. Don't try to write it. The sane production default is:
^[\w.+-]+@[\w-]+\.[\w.-]+$
Reading left to right:
[\w.+-]+— local part: word characters plus . + -@— literal at-sign[\w-]+— domain label (no dots inside)\.— literal dot[\w.-]+— TLD with allowed subdomains and hyphens
What this catches
Typos: missing @, missing TLD, spaces in addresses, completely invalid shapes. About 95% of "is this an email?" use cases.
What it MISSES (and why that's fine)
- Quoted local parts:
"hello world"@example.com— valid per spec, almost never used. - IP-literal domains:
user@[192.168.1.1]— same. - Non-ASCII Unicode local parts:
유저@한국.kr— needs Unicode flag and adjusted character classes. - Whether the email actually exists.
For real "does this email work?" — send a verification message. Regex can't tell you that.
The HTML5 alternative
Browsers' built-in type="email" validation uses a slightly more permissive regex. If you're in a browser, just use it: <input type="email" required>. Saves you the regex entirely.