Regex to Match an Email Address
Copy the pattern, paste your text below, and see every email it finds. Below the tester: what each part does, and why you should not try to match the full RFC.
Regex pattern
/[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}/g
This matches a practical email address like name@example.com (local part, @, domain, TLD). It covers the vast majority of real addresses; it is a format check, not proof the mailbox exists.
What this pattern matches
This expression matches the email addresses you actually see in real text: a local part, an @, a domain, and a top-level domain of at least two letters. It handles dots, plus-tags (name+tag@…), and sub-domains.
How it works, part by part
[A-Za-z0-9._%+-]+ — the local part: letters, digits, and the common symbols . _ % + -.
@ — the literal at-sign.
[A-Za-z0-9.-]+ — the domain, including any sub-domains separated by dots.
\.[A-Za-z]{2,} — a dot followed by a top-level domain of two or more letters.
Why not match the full spec
The official RFC 5322 grammar for email is enormous and allows addresses almost no real system accepts. A pragmatic pattern like this one catches essentially every address a user will type, without false-rejecting valid ones. For sign-up forms, the only reliable validation is sending a confirmation email.
Use it in your code
import re
text = "Reach me at jane.doe@example.com or sales+eu@shop.co.uk. Not an email: @nope, foo@bar (no TLD)."
pattern = r'''[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}'''
for m in re.finditer(pattern, text):
print(m.group())
const text = "Reach me at jane.doe@example.com or sales+eu@shop.co.uk. Not an email: @nope, foo@bar (no TLD).";
const re = new RegExp(String.raw`[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}`, "g");
console.log(text.match(re));
FAQ
Does it match plus-tagged addresses like name+tag@example.com?
Yes. The local-part class includes +, so name+tag@example.com matches.
Why require two letters in the TLD?
The {2,} quantifier rejects a bare foo@bar with no dot-suffix while allowing modern long TLDs like .studio or .co.uk.
Should I anchor it with ^ and $?
Only when validating a single input field. To find every email inside a block of text, leave it unanchored and use the g flag.