Regex guide
Email Regex Pattern
Email validation is one of the most common regex use cases, but also one of the easiest to overcomplicate. This guide explains a practical email regex and when you should avoid trying to match every theoretical address.
Suggested pattern
^[^\s@]+@[^\s@]+\.[^\s@]+$
What it matches
alice@example.com
contact+sales@example.co.uk
Common limitations
- Not fully RFC compliant.
- Some rare valid email addresses may be rejected.
Suggested pattern
^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$
What it matches
john.doe@example.com
user+tag@example.org
Common limitations
- ASCII-focused.
- Does not validate real domain existence.
Why use an email regex?
Email regex patterns are commonly used to validate email addresses in contact forms, registration pages, login screens and business applications.
A regex can quickly detect obvious formatting mistakes before data is sent to a server, improving user experience and reducing invalid submissions.
What makes email validation difficult?
Email addresses are more complex than they appear. The official standards allow many unusual formats that are rarely used in practice.
As a result, most applications use a practical email regex that accepts common addresses while rejecting obvious mistakes.
Common email validation rules
Most email regex patterns require a local part, an @ symbol and a domain name with a valid top-level domain.
Some applications also restrict special characters, enforce lowercase addresses or require company-specific domains.
Regex validation vs real email verification
A regex can verify the format of an email address, but it cannot determine whether the mailbox actually exists.
True email verification requires sending a confirmation email, checking DNS records or using dedicated validation services.
Should you use a strict or simple email regex?
Simple email regex patterns are easier to maintain and usually provide the best user experience.
Very strict patterns may reject legitimate addresses and create unnecessary frustration for users.