Email Validation Regex
Regex pattern for validating email addresses in JavaScript, Python, and more. Copy-paste ready with test cases.
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$About this pattern
This regex validates standard email addresses by checking for an alphanumeric local part (with common special characters like dots, underscores, percent, plus, and hyphen), followed by an @ symbol, a domain name with dots, and a top-level domain of at least 2 characters. It covers the vast majority of real-world email addresses while remaining simple enough to understand and maintain. For full RFC 5322 compliance, a significantly more complex pattern is needed, but this pattern is sufficient for 99.9% of form validation use cases.
FAQ
Does this regex catch all valid emails?
It catches all common email formats. Technically, RFC 5322 allows exotic addresses like "user@[IPv6:2001:db8::1]" which this pattern does not match, but these are extremely rare in practice.
Should I use regex or a library for email validation?
For quick client-side validation, regex is fine. For production systems, combine regex with an actual email verification step (sending a confirmation email) since regex cannot tell you if a mailbox exists.