Email Regex
The email regex that tells the truth — pragmatic and RFC 5321 strict variants, fifteen CI-verified rows and the live tester preloaded.
Pattern variants
Pragmatic
/^[^\s@]+@[^\s@]+\.[^\s@]+$/
What it matches
Any non-space local part, an @, and a domain that contains a dot — the shape almost every real address has.
What it deliberately doesn't
RFC 5322 grammar: quoted local parts, comments, IP-literal domains and dotless domains all fail here.
Strict
/^[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[A-Za-z0-9]+(?:-+[A-Za-z0-9]+)*\.)+[A-Za-z]{2,}$/
What it matches
An RFC 5321 dot-atom local part, then hyphen-safe (LDH) domain labels ending in a letters-only TLD of two or more characters.
What it deliberately doesn't
Quoted local parts, internationalized (non-ASCII) addresses, IP-literal domains and one-letter TLDs.
Verified vectors
| Input | Pragmatic | Strict | Note |
|---|---|---|---|
"a@b.co" | ✓ matches | ✓ matches | the shortest sane shape |
"a@b" | ✗ no match | ✗ no match | no dot in the domain |
"a b@c.d" | ✗ no match | ✗ no match | space in the local part |
"jane.doe+archive@mail.example.com" | ✓ matches | ✓ matches | plus-tagging survives both variants |
"Jane.Doe@Example.COM" | ✓ matches | ✓ matches | case is fine in both variants |
"john..doe@example.com" | ✓ matches | ✗ no match | consecutive dots — RFC 5321 dot-atom forbids them |
".user@example.com" | ✓ matches | ✗ no match | leading dot in the local part |
"user@example.c" | ✓ matches | ✗ no match | one-letter TLD |
"user@-bad-.example.com" | ✓ matches | ✗ no match | label starts and ends with a hyphen |
"user@example..com" | ✓ matches | ✗ no match | empty domain label |
"user@10.0.0.1" | ✓ matches | ✗ no match | IP-literal domain |
"имя@пример.рф" | ✓ matches | ✗ no match | internationalized address — strict is ASCII-only |
"user@exam ple.com" | ✗ no match | ✗ no match | space in the domain |
"user@@example.com" | ✗ no match | ✗ no match | two @ signs |
"no-at-sign.example.com" | ✗ no match | ✗ no match | no @ at all |
Usage by language
JavaScript
Machine-verified/^[^\s@]+@[^\s@]+\.[^\s@]+$/
/^[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[A-Za-z0-9]+(?:-+[A-Za-z0-9]+)*\.)+[A-Za-z]{2,}$/
Python
Machine-verifiedre.compile(r"^[^\s@]+@[^\s@]+\.[^\s@]+$")
re.compile(r"^[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[A-Za-z0-9]+(?:-+[A-Za-z0-9]+)*\.)+[A-Za-z]{2,}$")
Java
Syntax-reviewed — not machine-verifiedPattern.compile("^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$")
Pattern.compile("^[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[A-Za-z0-9]+(?:-+[A-Za-z0-9]+)*\\.)+[A-Za-z]{2,}$")
Go
Syntax-reviewed — not machine-verifiedregexp.MustCompile(`^[^\s@]+@[^\s@]+\.[^\s@]+$`)
regexp.MustCompile("^[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[A-Za-z0-9]+(?:-+[A-Za-z0-9]+)*\\.)+[A-Za-z]{2,}$")
The pattern contains a backtick, so Go cannot hold it in a raw string literal — shown as a double-quoted interpreted string instead.
The strict pattern contains a backtick, so it cannot sit in a Go raw string literal — it is shown as a double-quoted interpreted string instead.
C#
Syntax-reviewed — not machine-verifiednew Regex(@"^[^\s@]+@[^\s@]+\.[^\s@]+$")
new Regex(@"^[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[A-Za-z0-9]+(?:-+[A-Za-z0-9]+)*\.)+[A-Za-z]{2,}$")
PHP
Syntax-reviewed — not machine-verified'/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/'
'/^[A-Za-z0-9!#$%&\'*+\\/=?^_`{|}~-]+(?:\\.[A-Za-z0-9!#$%&\'*+\\/=?^_`{|}~-]+)*@(?:[A-Za-z0-9]+(?:-+[A-Za-z0-9]+)*\\.)+[A-Za-z]{2,}$/'
Caveats
- Full RFC 5322 validation by regex is a fool's errand — validate pragmatically, then confirm by sending.
- These are anchored whole-field validators; to find addresses inside text, drop the anchors and expect more false positives.
- The classic community email regex below backtracks catastrophically — never deploy it; the live tester's 1-second watchdog is the safe place to see why.
Related patterns
Do it offline:$ grep -E '^[^[:space:]@]+@[^[:space:]@]+\.[^[:space:]@]+$' emails.txt
How to use it
- Copy the pragmatic line for signup forms and log filters — it keeps plus-tagged addresses that folklore patterns turn away.
- Flip the selector to strict where the value feeds SMTP: dot-atom rules refuse consecutive dots, hyphen-edged labels and one-letter TLDs.
- Find the vectors row closest to your data, then confirm with a real delivery — a match proves shape, never a mailbox.
One regex cannot honestly cover the full RFC 5322 grammar — chasing it is a fool's errand of quoted local parts and nested comments. This page gates addresses pragmatically: one @, no spaces, a dot in the domain. An RFC 5321 dot-atom strict variant, fifteen CI-verified vectors and six language spellings follow, with the live tester preloaded above.
Examples
^[^\s@]+@[^\s@]+\.[^\s@]+$pattern /^[^\s@]+@[^\s@]+\.[^\s@]+$/
jane.doe+archive@mail.example.com ✓ matches
Jane.Doe@Example.COM ✓ matches
user@exam ple.com ✗ no match
no-at-sign.example.com ✗ no matchDots, plus signs and capitals ride through untouched; a space anywhere or a missing @ ends the match on the spot.
^[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[A-Za-z0-9]+(?:-+[A-Za-z0-9]+)*\.)+[A-Za-z]{2,}$pragmatic /^[^\s@]+@[^\s@]+\.[^\s@]+$/
strict /^[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[A-Za-z0-9]+(?:-+[A-Za-z0-9]+)*\.)+[A-Za-z]{2,}$/
john..doe@example.com pragmatic ✓ matches strict ✗ no match
.user@example.com pragmatic ✓ matches strict ✗ no match
a@b.co pragmatic ✓ matches strict ✓ matchesDoubled and leading dots break the dot-atom rule: strict turns both away where the shape gate shrugs; a plain short address satisfies the pair.
Every example on this page is executed against the same engine that powers the tool, on every build.
Gotchas worth knowing
The community classic that melts CPUs
The caveats block prints one famous email regex whose nested quantifiers double its matching time with each extra character in a failing tail. It appears only as a warning — probe suspect candidates in the tester, whose one-second watchdog kills runaways.
Common errors
Invalid regular expression: /*@example.com/: Nothing to repeat- A shell glob is not a regex: * multiplies whatever precedes it, and here nothing does. Spell any-characters as .* — or take the anchored pattern above, which covers the whole field.
FAQ
Why does the pragmatic email pattern accept user@10.0.0.1?
Nothing in its three chunks forbids digits — the domain just needs a dot and no whitespace. If IP-literal hosts must fail, use strict, which wants labeled names under a letters-only TLD.
Does a match prove the address can receive mail?
No — it proves the string is shaped like an address. Typos inside real domains still pass, so serious flows send a confirmation and treat the click as the verdict.
How do I find addresses inside a larger document?
Delete the ^ and $ anchors and add the g flag in the embedded tester — anchored validators check one whole field by design. Expect extra hits, and skim before trusting them.