Simple validation patterns
Basic email regex (practical)
/^[^\s@]+@[^\s@]+\.[^\s@]+$/
Example:
/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$/
Allow plus addressing
/^[\w.+-]+@example\.com$/
Example:
/^[\w.+-]+@[\w.-]+\.[A-Za-z]{2,}$/
Extraction patterns
Find emails in text
/[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}/g
Example:
grep -E -o "[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}" mail.txt
Mask domain in output
email.replace(/@.*/, "@hidden")
Example:
text.replace(/[A-Za-z0-9._%+-]+@[^\s]+/g, "[redacted]")
Validation workflow tips
Pair regex with confirmation email
if (/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(input)) sendVerification()
Example:
// verify ownership by email link
Normalize before validate
email.trim().toLowerCase()
Example:
email.normalize("NFKC")
Common mistakes / Errores comunes
- Regex cannot fully validate RFC-complete email syntax or mailbox existence.
- Overly strict patterns block valid internationalized addresses.
- Not trimming whitespace before validation causes false negatives.
Last updated: February 2026