Visual regex workbench

Build, test, explain and master regex with visual tools, guides, examples and a growing regex library.

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.

Basic email validation

Validates the basic structure of an email address.

Suggested pattern

^[^\s@]+@[^\s@]+\.[^\s@]+$
Quick test

What it matches

  • alice@example.com
  • john@test.org

Common limitations

  • Checks only the general format.
  • Does not verify whether the domain or mailbox actually exists.

Practical email validation

A practical email validation pattern suitable for many web forms.

Suggested pattern

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

What it matches

  • alice@example.com
  • john.doe+shop@test.co.uk

Common limitations

  • Does not implement the complete RFC specification.
  • Should be combined with confirmation emails or server-side verification.

Email with subdomains

Matches email addresses using one or more subdomains.

Suggested pattern

^[^\s@]+@(?:[A-Za-z0-9-]+\.)+[A-Za-z]{2,}$
Quick test

What it matches

  • alice@mail.example.com
  • john@example.co.uk

Common limitations

  • Still validates only the structure.

Gmail addresses only

Accepts only Gmail addresses.

Suggested pattern

^[A-Za-z0-9._%+-]+@gmail\.com$
Quick test

What it matches

  • alice@gmail.com
  • bob@gmail.com

Common limitations

  • Useful only when Gmail addresses are specifically required.

Corporate email address

Restricts addresses to a single company domain.

Suggested pattern

^[A-Za-z0-9._%+-]+@company\.com$
Quick test

What it matches

  • alice@company.com
  • sales@company.com

Common limitations

  • The domain must be adapted to your organization.

Extract email addresses

Extracts email addresses from text.

Suggested pattern

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

What it matches

  • alice@example.com
  • bob@test.org

Common limitations

  • May also match invalid addresses embedded in malformed text.

Comma-separated email list

Validates a comma-separated list of email addresses.

Suggested pattern

^\s*[^\s@]+@[^\s@]+\.[^\s@]+(?:\s*,\s*[^\s@]+@[^\s@]+\.[^\s@]+)*\s*$
Quick test

What it matches

  • alice@example.com, bob@test.org

Common limitations

  • Designed for comma-separated lists only.

Email with plus alias

Accepts email aliases using the plus sign.

Suggested pattern

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

What it matches

  • john+shop@example.com
  • alice+newsletter@gmail.com

Common limitations

  • Some systems choose to normalize or restrict aliases for business reasons.

Email domain only

Extracts only the domain part after the @ symbol.

Suggested pattern

(?<=@)[A-Za-z0-9.-]+\.[A-Za-z]{2,}
Quick test

What it matches

  • example.com
  • mail.company.org

Common limitations

  • Uses lookbehind, so check compatibility with your regex engine.

Username part of email

Extracts the local part before the @ symbol.

Suggested pattern

^[^\s@]+(?=@)
Quick test

What it matches

  • alice
  • john.doe

Common limitations

  • Designed for one email address per line.

Email ending with specific TLD

Accepts only email addresses ending with a specific top-level domain.

Suggested pattern

^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.org$
Quick test

What it matches

  • team@example.org
  • support@test.org

Common limitations

  • Change .org to the TLD required by your use case.

Business email address

Accepts email addresses that do not belong to common free email providers.

Suggested pattern

^[A-Za-z0-9._%+-]+@(?!gmail\.com$|yahoo\.com$|hotmail\.com$|outlook\.com$)[A-Za-z0-9.-]+\.[A-Za-z]{2,}$
Quick test

What it matches

  • alice@company.com
  • sales@example.org

Common limitations

  • Only excludes the providers listed in the pattern.

Extract multiple email addresses

Extracts every email address found in a text.

Suggested pattern

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

What it matches

  • sales@example.com
  • help@test.org
  • ceo@company.com

Common limitations

  • May also match malformed addresses that look valid.

Mask email addresses

Finds email addresses before replacing them with hidden values.

Suggested pattern

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

What it matches

  • alice@example.com
  • bob@test.org

Common limitations

  • The replacement itself depends on your programming language.

Email without plus aliases

Rejects email aliases containing the plus sign.

Suggested pattern

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

What it matches

  • alice@example.com

Common limitations

  • Rejects valid addresses used by many email providers.

Allowed top-level domains

Restricts email addresses to a predefined list of top-level domains.

Suggested pattern

^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.(?:com|org|net)$
Quick test

What it matches

  • alice@example.com
  • bob@test.org

Common limitations

  • Requires regular updates as new TLDs appear.

Why email regex validation is difficult

Email addresses look simple, but the official syntax is much more flexible than most people expect.

In real applications, a practical regex usually checks the common structure instead of trying to implement every possible RFC-valid address.

The goal is usually to catch obvious mistakes, not to prove that an address exists or can receive mail.

Practical email regex vs RFC-compliant regex

Fully RFC-compliant email regexes are often extremely long, difficult to read and hard to maintain.

For most forms, a practical regex combined with email confirmation is safer and easier to understand.

Use strict RFC validation only when your application specifically needs to accept every valid edge case.

What an email regex can validate

An email regex can check for a local part, an @ symbol, a domain name and a top-level domain.

It can also restrict characters, require a minimum TLD length or reject whitespace.

However, it cannot confirm DNS records, mailbox existence or whether the address belongs to the user.

Email aliases and plus addressing

Many email providers support aliases such as john+shop@example.com.

Rejecting the plus sign can block valid users, especially on Gmail and developer-oriented services.

Unless you have a specific reason to forbid aliases, your regex should usually allow plus addressing.

International email addresses

Modern email systems can support internationalized domain names and, in some contexts, non-ASCII local parts.

Many simple email regexes intentionally focus on ASCII-only addresses because they are easier to support consistently.

If your application targets international users, test Unicode behavior carefully and consider using dedicated email validation libraries.

Confirming an email address

The most reliable way to verify an email address is usually to send a confirmation message.

A regex can reduce typos, but only confirmation proves that the user can access the mailbox.

For account creation, password reset and sensitive workflows, email confirmation is more important than making the regex stricter.

Frequently Asked Questions

What is the best regex for email validation?

There is no single "best" email regex. The right choice depends on your application and the level of validation you need.

For most web forms, a practical regex that checks the general structure is sufficient when combined with email confirmation.

Can regex validate every valid email address?

No. The official email specification allows many uncommon formats that are rarely used in practice.

Most applications intentionally use a simpler regex because it is easier to maintain and provides a better user experience.

Can regex verify that an email address exists?

No. A regex can only validate the format of an address.

To verify that an email really exists, you need confirmation emails or dedicated verification services.

Should I allow plus aliases?

Usually yes. Many providers such as Gmail support addresses like john+shop@gmail.com.

Rejecting them may prevent legitimate users from registering.

Should email validation happen on the client or the server?

Client-side validation improves the user experience by catching typing mistakes immediately.

Server-side validation remains essential because client-side checks can always be bypassed.

Why does my email regex reject valid addresses?

Many simple regexes intentionally reject uncommon but technically valid email formats.

Review the assumptions made by your pattern and test it with realistic examples before deploying it.

Continue learning

πŸ“˜ Recommended guide

Regex Limitations

An email regex can check the general shape of an address, but it cannot confirm that the mailbox exists or can receive messages.

Use regex for basic format validation, then rely on confirmation emails or server-side checks when real deliverability matters.

Read the complete guide β†’
πŸ“˜ Recommended guide

Testing Regex

Email patterns should be tested with simple addresses, subdomains, plus signs, invalid domains and malformed input.

Testing both accepted and rejected examples helps avoid overly strict or overly permissive validation.

Read the complete guide β†’
πŸ“˜ Recommended guide

Input Validation Best Practices

Email validation works best when regex is combined with normalization, clear error messages and server-side verification.

Read the complete guide β†’
πŸ“˜ Recommended guide

Common Regex Mistakes

Email regexes often become too strict, too permissive or unnecessarily complex.

Common mistakes include trying to be fully RFC-compliant, forgetting edge cases or relying on regex as the only validation layer.

Read the complete guide β†’
πŸ“˜ Recommended guide

Character Classes

Email regexes are built almost entirely from character classes such as [A-Za-z0-9], \w and custom character sets.

Understanding these building blocks makes email patterns much easier to read and adapt.

Read the complete guide β†’
πŸ“˜ Recommended guide

Quantifiers

Email validation also relies on quantifiers to define minimum lengths, optional characters and repeated sections.

Mastering quantifiers helps you understand why common email regexes are written the way they are.

Read the complete guide β†’