Regex Email Patterns Reference
Reference 为 email validation regex patterns 从简单到 RFC 5322 compliant.
Validation Approaches
Simple validation: ^[^@]+@[^@]+\.[^@]+$ checks basic structure. Moderate: ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$ restricts characters. RFC 5322 compliant patterns are extremely complex (see regex reference). No regex can fully validate email deliverability; only sending a confirmation email verifies. Overly strict patterns reject valid addresses (e.g., plus addressing, IDN domains). The pragmatic approach: check for @ and a dot in the domain, then verify via email.
- simple
- Basic @ and dot
- moderate
- Character restricted
- RFC 5322
- Fully compliant
permissive common use very complex Edge Cases
Plus addressing ([email protected]) is valid and useful for filtering. Subdomains ([email protected]) are valid. IDN domains (user@münchen.de) require Punycode or /u flag. Quoted local parts ("user name"@domain.com) are valid but rare. Multiple @ signs are invalid except in quoted parts. Length limits: 64 chars local part, 255 chars domain, 254 total. Comments in parentheses are technically valid but unsupported in practice. Always normalize to lowercase for comparison.
- plus addressing
- user+tag@domain
- IDN
- Unicode domains
- length
- 64 local, 255 domain
valid, useful Punycode RFC limits