Email Regex Pattern — Validate Email Addresses with Regular Expressions

The complete guide to email validation with regex. Get battle-tested patterns, understand how they work, and test them with your own data — all in one place.

Standard Email Regex Pattern

[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}

This pattern matches most standard email addresses including those with dots, underscores, percent signs, plus signs, and hyphens in the username, followed by a domain with at least a two-letter TLD.

//
Flags:

Substitution

No matches found

How the Email Regex Works

The standard email regex pattern breaks down into three main parts: the local part (username), the @ symbol, and the domain part. Let's examine each component:

[a-zA-Z0-9._%+-]+

Local part (username):Matches one or more letters, digits, dots, underscores, percent signs, plus signs, or hyphens. This covers standard usernames like "john.doe", "user+tag", and "info%40".

@

At symbol: The literal @ character separating the local part from the domain. Every valid email address requires exactly one @.

[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}

Domain part:Matches the domain name (letters, digits, dots, hyphens) followed by a dot and a top-level domain of at least two letters. This handles domains like "gmail.com", "mail.company.co.uk", etc.

Email Regex Patterns Compared

Different use cases call for different levels of email validation. Here are the most common approaches:

Simple Pattern (Recommended for most uses)

\S+@\S+\.\S+

Quick and dirty: matches anything with @ and a dot. Good for extracting emails from text, not for strict validation.

Standard Pattern (Best balance)

[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}

The sweet spot: validates structure while remaining readable and maintainable. Catches most typos and invalid formats.

Strict Pattern (For maximum validation)

^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$

Closer to RFC 5322 compliance. Handles more special characters and enforces domain label length limits. Use when you need stricter validation.

Common Email Validation Edge Cases

Email addresses are more varied than most people expect. Here are edge cases your regex should handle:

user+tag@gmail.com

Plus addressing (Gmail aliases)

user.name@domain.com

Dots in local part

user@sub.domain.com

Subdomains in domain

user@domain.co.uk

Multi-part TLDs

user@domain

Missing TLD

@domain.com

Missing local part

user@@domain.com

Double @ symbol

user@.com

Domain starts with dot

Email Regex in Different Programming Languages

The email regex pattern works across most programming languages with minimal modifications. Here's how to use it:

JavaScript

const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
const isValid = emailRegex.test("user@example.com");

Python

import re
email_regex = r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$'
is_valid = re.match(email_regex, "user@example.com")

PHP

$email = "user@example.com";
$pattern = '/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/';
$isValid = preg_match($pattern, $email);

Best Practices for Email Validation

  • Use regex for format validation only

    Regex checks that the email looks like a valid address. It cannot verify that the email actually exists or can receive mail.

  • Combine with confirmation emails

    The only way to truly verify an email address is to send a confirmation email. Use regex as a first-pass filter, then confirm via email.

  • Validate on both client and server

    Client-side regex validation gives instant feedback. Always re-validate on the server since client-side checks can be bypassed.

  • Be permissive, not restrictive

    It's better to accept a slightly invalid email (and let the confirmation email fail) than to reject a valid one. Overly strict regex can block real users.

Test Your Email Regex Now

Paste the email regex pattern into the tester above and verify it with your own test data. Free, instant, and private.