NC Logo UseToolSuite
Text Processing

Email Validation Regex: Patterns That Actually Work

Practical regex patterns for email validation in JavaScript, Python, and HTML forms. Learn what works, what doesn't, and why you should send a confirmation email.

Necmeddin Cunedioglu Necmeddin Cunedioglu

Practice what you learn

Regex Tester

Try it free →

Email Validation Regex: Patterns That Actually Work

Email validation is one of the most common regex use cases — and one of the most frequently done wrong. This guide provides practical patterns you can use immediately.

For most applications, this pattern provides the best balance of accuracy and simplicity:

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

This matches: one or more non-whitespace, non-@ characters, an @ symbol, one or more non-whitespace, non-@ characters, a dot, and one or more non-whitespace, non-@ characters.

Test it now: Paste this pattern into our Regex Tester and try various email addresses.

Matches: user@example.com, user+tag@sub.domain.com, 名前@example.jp

Rejects: @example.com, user@, user @example.com

The Strict Pattern

For stricter validation (standard ASCII emails only):

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

This pattern is used by many web frameworks and libraries. It requires:

  • Local part: letters, digits, dots, underscores, percent, plus, hyphen
  • Domain: letters, digits, dots, hyphens
  • TLD: at least 2 letters

Patterns to Avoid

The “Perfect” RFC 5322 Pattern

The full RFC 5322 email specification is incredibly complex. The “complete” regex is over 6,000 characters long and matches edge cases like:

"quoted string"@example.com
user@[192.168.1.1]

Don’t use this. It’s unmaintainable, and these edge-case addresses rarely exist in practice.

Overly Restrictive Patterns

^[a-z]+@[a-z]+\.[a-z]{3}$

This rejects valid addresses like:

  • user.name@example.com (dots in local part)
  • USER@example.com (uppercase)
  • user+tag@example.com (plus addressing)
  • user@example.co.uk (multi-part TLDs)

Language-Specific Implementations

JavaScript

function isValidEmail(email) {
  return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email);
}

Python

import re

def is_valid_email(email: str) -> bool:
    pattern = r'^[^\s@]+@[^\s@]+\.[^\s@]+$'
    return bool(re.match(pattern, email))

HTML5 (No Regex Needed)

<input type="email" required />

The type="email" attribute provides built-in browser validation.

The Golden Rule

Regex validates format; confirmation validates existence. The only way to truly verify an email address is to send a confirmation email with a verification link. Use regex as a first-pass filter, then verify with email delivery.


This article is part of our Regular Expressions Guide series.

Necmeddin Cunedioglu
Necmeddin Cunedioglu Author

Software developer and the creator of UseToolSuite. I write about the tools and techniques I use daily as a developer — practical guides based on real experience, not theory.