Regex Email Validation — Patterns with Examples
No single regex validates all valid email addresses perfectly — the spec is too complex. Pick the pattern that matches your requirements: use the simple pattern for most apps, the strict pattern for tighter validation, or the HTML5 pattern to match browser behavior.3 Email Regex Patterns
Simple email pattern
/^[^s@]+@[^s@]+.[^s@]+$/Does not match
user@
@domain.com
not-an-email
Good for most use cases. Fast and permissive.
Strict RFC-5321 pattern
/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,}$/Covers most valid emails. Rejects spaces and malformed domains.
HTML5 email pattern (browser spec)
/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/Does not match
plainaddress
@missinglocal.com
Matches what browsers use for <input type='email'>.
Code Examples
JavaScript
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
function isValidEmail(email) {
return emailRegex.test(email);
}
console.log(isValidEmail("[email protected]")); // true
console.log(isValidEmail("not-valid")); // falsePython
import re
pattern = r'^[^\s@]+@[^\s@]+\.[^\s@]+$'
def is_valid_email(email):
return bool(re.match(pattern, email))
print(is_valid_email("[email protected]")) # True
print(is_valid_email("not-valid")) # FalseTest Your Pattern Online
Related Guides
- → Regex URL Pattern
- → Regex Password Validation
- → Regex Numbers Only Pattern
- → Common Regex Patterns
- → Regex Date Format
- → Regex Phone Number
Frequently Asked Questions
Which regex should I use to validate emails?
For most apps, the simple pattern /^[^\s@]+@[^\s@]+\.[^\s@]+$/ is sufficient. Use the strict RFC pattern if you need tighter validation.
Should I validate emails with regex or a library?
For production apps, use a dedicated library or send a verification email — regex alone will miss edge cases. Regex is good for basic client-side filtering.
What is the HTML5 email regex?
Browsers use a built-in pattern for <input type="email"> defined in the HTML5 spec. It's more permissive than RFC 5321 but aligns with real-world email formats.
All tools run in your browser. Your data never leaves your device.