Advertisement

Email Regex Tester & Patterns

Copy a tested email regex (simple, practical, HTML5 or strict), check a list of addresses against it and get the code for JavaScript, Python, PHP or Java.

An email regex decides which strings look like an address before you accept a sign-up or send a message. This tool gives you four ready-made patterns of increasing strictness plus an extractor, tests every line you paste against the one you pick, says why each failing line fails, and writes the matching code for JavaScript, Python, PHP or Java.

How to use this tool

  1. Choose a pattern — Practical suits most forms; Strict adds the RFC 5321 length and dot rules.
  2. Paste addresses, one per line, or choose "Find emails inside any text" and paste a page, log or CSV.
  3. Read the Valid and Invalid counts and the reason given for each failing line.
  4. Pick your language and copy the code snippet.

Formula

Practical: ^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$

Before the @: letters, digits and . _ % + -. After it: a domain containing a dot and ending in at least two letters. The HTML5 pattern is the rule browsers apply to <input type="email">; it allows more symbols before the @ and does not require a dot in the domain. Strict uses two lookaheads to cap the part before the @ at 64 characters and the whole address at 254, and forbids leading, trailing or doubled dots. Strict is a limited dot-atom pattern, not a complete RFC validator. Cross-language whitespace classes differ; test non-ASCII whitespace in the target runtime. The table shows at most 400 lines or matches.

Example

The default list has six lines. With Practical, three pass: john.doe@example.com, jane_smith+news@mail.co.uk and a..b@example.com. user@localhost fails (no dot in the domain), not-an-email has no @, and name@domain.c ends in a one-letter TLD. Switch to HTML5 and five pass, because the browser rule accepts a single-label domain, a one-letter ending and doubled local dots. Strict passes only two, because it also rejects the doubled dot in a..b@example.com.

Frequently asked questions

Is there a perfect email regex?

No. The full email grammar includes quoted local parts and address literals that these patterns intentionally omit. No regex can tell whether a mailbox exists; confirm ownership with a verification link.

Why does the HTML5 pattern accept user@localhost?

The HTML standard permits a single-label host. Practical and Strict require a dotted domain, but a match still does not prove that the domain or mailbox exists.

Are international addresses supported?

The ASCII patterns do not support Unicode local parts. Simple is more permissive. HTML5 accepts ASCII punycode domain labels; Strict also allows an xn-- top-level label. Practical requires a letters-only ending, so it rejects punycode top-level domains.

Should I compare addresses case-insensitively?

Domain names are case-insensitive. RFC 5321 requires preserving the case of the local part before @, because a receiving system may treat it as significant. Keep the submitted local part unless you have a provider-specific rule.

Sources

Last updated: 2026-10-30

Advertisement