A solid regular expression (regex) stops obvious typos like missing @ signs or bad TLDs. But format checks alone can’t spot temporary or throwaway inboxes. This guide shows a safe, production-ready regex, explains its pieces, and covers why pairing it with a
disposable email checker is essential for list quality and deliverability.
This pattern balances correctness and practicality for most web apps and APIs:
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[A-Za-z]{2,}$
^ and $ anchor the start/end so partial matches don’t pass.[a-zA-Z0-9._%+-]+ allows typical local-part characters (e.g., john.doe+promo).@ requires the separator.[a-zA-Z0-9.-]+ covers subdomains like mail.sales.\.[A-Za-z]{2,} enforces a 2+ letter TLD (e.g., .io, .travel).Regex confirms syntax, not deliverability. It won’t detect disposable domains (e.g., Mailinator variants), parked or misconfigured MX, or inboxes that accept then bounce later. To block low-quality signups, pair your regex with domain-level checks via our Disposable Email Checker.
const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[A-Za-z]{2,}$/;
function isValidEmailFormat(email) {
return emailRegex.test(email);
}
// Example usage
const email = "[email protected]";
if (isValidEmailFormat(email)) {
console.log("Looks good — now check disposables via API.");
} else {
console.log("Invalid email format.");
}
import re
EMAIL_RE = re.compile(r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[A-Za-z]{2,}$')
def is_valid_email_format(s: str) -> bool:
return EMAIL_RE.match(s) is not None
After the regex pass, query our Disposable Email Checker to identify throwaway domains in real time. We use domain intelligence, MX/DNS checks, and reputational signals to flag risky addresses without sending any email to the recipient.
No. Regex only validates structure. Use DNS/MX checks and disposable detection; final deliverability is only certain after a real send.
RFC-complete patterns are huge and fragile for clientside use. The above regex is a pragmatic choice used widely in production.
For IDN domains, convert to punycode server-side before applying the regex, or validate with a library that supports IDNA.