Home >Blog

Regex to Match an Email Address and Reject Fake Ones

Published Updated

Start with shape, end with verification. A regex can reject malformed and obviously fake addresses, but it cannot tell you whether the mailbox actually exists — that information is not in the string. The pattern below is a solid starting filter; everything else is layered checks on top of it.

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

The questions below cover the limits and the layered approach.

What is the most common regex pattern for matching an email address?
The short version everyone starts with: ^[^@\s]+@[^@\s]+\.[^@\s]+$. It rejects strings with spaces and requires one @ with a dot after it. It is a good first filter and a bad final one — plenty of fake inputs like [email protected] pass through.

Why does a simple email regex still match fake addresses?
Because regex only checks the shape, not the mailbox. [email protected] is a valid shape but useless in practice. A regex can reject malformed strings, but it can't know whether the address exists, is disposable, or belongs to someone. Format checks and existence checks are different jobs.

Should I use one long regex or several small checks?
Several small checks. A single monster pattern is hard to read, easy to break, and still gets bypassed. Do it in layers: length limit, no spaces, exactly one @, a domain with a dot, allowed character set. Each layer is testable on its own.

How do I reject obviously fake email addresses with regex?
Block the cheap tells first: addresses like test@, qwerty@, or [email protected], plus common placeholder domains like example.com. Keep the blacklist short and explicit. Anything beyond that — catch disposable domains, verify the mailbox, check if the domain resolves — needs more than regex.

Do regex email checks work for user signup forms?
As a first gate, yes. As the only gate, no. Use the regex to reject the clearly invalid input, then do a real check: confirm the domain has an MX record, and send a verification email. Most fake signups pass the regex and die at the verification step.

What characters are actually allowed in an email address?
The local part allows letters, digits, and ._%+- in most real-world implementations, and the domain part is much stricter: letters, digits, hyphens, and dots. Most sites deliberately support less than the full RFC 5322 spec — that's fine, be strict for your own use case.

Why do some regexes allow a dot at the start or end of the local part?
Because they copied a pattern that was never tested against edge cases. A dot at the start, end, or in a double-dot sequence like [email protected] is invalid per the spec. If you want correct output, anchor the pattern and add the dot rules explicitly.

Is there a regex that rejects 100% of fake emails?
No. There is no regex in existence that separates a real mailbox from a fake one, because that information isn't in the string. The best a regex can do is reject the malformed and the obvious fakes. After that you verify, you don't pattern-match.

Test your own pattern against tricky inputs in the email regex tester here before you ship it.

FAQ

What is the most common regex pattern for matching an email address?
^[^@\s]+@[^@\s]+\.[^@\s]+$ rejects strings with spaces and requires one @ with a dot after it. Good first filter, bad final one — [email protected] passes.
Why does a simple email regex still match fake addresses?
Regex only checks shape, not the mailbox. It can reject malformed strings but can't know whether the address exists, is disposable, or belongs to someone. Format checks and existence checks are different jobs.
Should I use one long regex or several small checks?
Several small checks. A single monster pattern is hard to read, easy to break, and still gets bypassed. Layer it: length limit, no spaces, exactly one @, a domain with a dot, allowed characters.
How do I reject obviously fake email addresses with regex?
Block the cheap tells first: test@, qwerty@, [email protected], placeholder domains like example.com. Keep the blacklist short and explicit. Disposable domains and mailbox checks need more than regex.
Do regex email checks work for user signup forms?
As a first gate, yes. As the only gate, no. Reject the clearly invalid input with regex, then confirm the domain has an MX record and send a verification email.
What characters are actually allowed in an email address?
The local part allows letters, digits, and ._%+- in most real-world implementations; the domain is stricter — letters, digits, hyphens, dots. Being stricter than the RFC is fine.
Why do some regexes allow a dot at the start or end of the local part?
They copied a pattern never tested against edge cases. A dot at the start, end, or double-dot sequences are invalid. Anchor the pattern and add dot rules explicitly.
Is there a regex that rejects 100% of fake emails?
No. No regex can separate a real mailbox from a fake one — that information isn't in the string. Reject the malformed and obvious fakes, then verify.

Table of Contents

Information

  • Hits47
  • Published date2026/10/10
0/500
Share your thoughts respectfully.

More Posts

Explore more articles from this section
Regex for IP Addresses: Accurate IPv4 and IPv6 Validation Examples
Sep 09, 2026450views

Regex for IP Addresses: Accurate IPv4 and IPv6 Validation Examples

Use regex to find possible IP addresses, then use the right validation rule for the job. This guide covers loo...

#regex for IP address#IP address regex#IPv4 regex#IPv6 regex
Password Validation Regex: Examples for Length, Numbers, Symbols, and Strong Passwords
Sep 07, 2026447views

Password Validation Regex: Examples for Length, Numbers, Symbols, and Strong Passwords

Learn practical password validation regex patterns for length, digits, symbols, and mixed character classes. T...

#password validation regex#regex for password validation#strong password regex#regex lookahead
How to Validate a URL with Regex: HTTP, HTTPS, Domains, and Query Strings
Sep 03, 2026385views

How to Validate a URL with Regex: HTTP, HTTPS, Domains, and Query Strings

Build a practical HTTP and HTTPS URL regex by separating schemes, DNS domains, ports, paths, query strings, an...

#URL validation regex#regex for URL validation#HTTP URL regex#HTTPS URL regex
How to Extract Email Addresses from Text with Regex in Python and JavaScript
Sep 15, 2026345views

How to Extract Email Addresses from Text with Regex in Python and JavaScript

Extract email addresses from any text with regex in Python and JavaScript: the pattern explained piece by piec...

#regex extract email#email regex python#email regex javascript#extract emails from text
What Regex Should You Use for Phone Numbers? Patterns for US and International Formats
Aug 28, 2026328views

What Regex Should You Use for Phone Numbers? Patterns for US and International Formats

Compare practical regex patterns for US formatted numbers, normalized local numbers, plus-prefixed internation...

#phone number regex#regex for phone number#US phone regex#international phone regex
How to Replace Text with Python Regex: re.sub() Examples and Common Mistakes
Sep 18, 2026323views

How to Replace Text with Python Regex: re.sub() Examples and Common Mistakes

Learn how to replace text safely with Python re.sub(), including capture groups, callback functions, case-inse...

#python regex replace#re.sub#regex capture groups#regex callback
Feedback email