Real-World Validation PatternsLesson 5.1
Email validation with regex what actually works
RFC 5321 overview, practical email regex, local part rules, domain rules, TLD length, common false positives, validation tradeoffs
Perfect Email Regex Does Not Exist โ Useful Ones Do
RFC 5321 allows email addresses that no real provider accepts. The practical goal is rejecting obvious non-emails, not achieving 100% RFC compliance.
const emailRe = /^[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}$/;
emailRe.test('user@example.com') // true
emailRe.test('user@') // false โ no domain
For production systems, send a confirmation email โ regex validates format, not deliverability.
