chrome-extension://regex-tester-pro · live preview

Pattern

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

Test string

Updated sergey+stripe@regios.org for Chromium 124

flags: i · 1 match · 0.4 ms

All matching happens in your browser. Patterns and test strings never leave the tab.

Regex Guide

Regex for Email Validation: The Pattern Every Developer Should Know

Updated May 2026 8 min read By the Regex Tester Pro team

Quick answer

Use /^[\w.+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$/ for client-side checks. It catches typos and rejects anything obviously not an email, but it will not (and should not) try to validate the full RFC 5322 grammar. Pair it with a confirmation email for ground truth.

Email regex is the canonical example of a problem where "good enough" beats "perfectly correct". RFC 5322 allows quoted local parts, comments, and IP-literal domains. No real signup form needs that. Here is the pattern most teams actually ship.

JavaScript
// Practical email validation, two patterns
const looksLikeEmail = /^[\w.+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$/;

function isValidEmail(input) {
  if (!looksLikeEmail.test(input)) return false;
  // Reject the most common typos in TLDs
  if (/\.(con|cmo|comm)$/i.test(input)) return false;
  return true;
}

isValidEmail('sergey+stripe@regios.org');  // true
isValidEmail('not-an-email');              // false
isValidEmail('user@domain.con');           // false (typo)

The pattern, explained piece by piece

Break it down:

This rejects "user@", "@domain.com", "user@domain", and "user @domain.com". It accepts plus-addressing (sergey+stripe@regios.org) and dotted local parts (first.last@company.com), which most users expect.

Why not the full RFC 5322 regex

The official grammar allows things no real signup form should accept. Quoted local parts ("user with spaces"@example.com), IP-literal domains (user@[192.168.1.1]), comments inside addresses (user(work)@example.com). The fully compliant regex is over 6,000 characters long and famously broken in many published versions.

What you actually want is a syntactic sniff test, plus a confirmation email loop. The regex catches typos at the input field. The confirmation email proves the address routes to a real human. Trying to make the regex do both is how you end up rejecting legitimate +-addressed Gmail users on a Tuesday morning.

What to do for the 1% the regex misses

Three known gaps in the simple pattern:

Common mistakes in published email regex

You will see three failure modes on Stack Overflow:

  1. Hard-coded TLD list. Patterns that allow only com|org|net|edu|gov|mil|info were already wrong in 2008. Today there are over 1,500 TLDs in DNS root.
  2. Using \w for the domain. \w includes underscores, which are not valid in domain labels. Stick to [A-Za-z0-9.-] for that segment.
  3. Forgetting anchors. Without ^ and $, not-an-email-but-has@something.com-extra will pass test(). Always anchor.

If you are pasting a regex from a forum, run it against a list of 30 weird-but-valid emails (plus-addressed, dotted, all-numeric local part, single-letter TLD attempt) before shipping.

Validation in different languages

Same intent, different syntax:

Languages that do not support possessive quantifiers do not need them here. Languages that lack lookbehind do not need it either. The pattern is portable, which is part of why it has aged well.

When to use a library instead

For server-side validation, prefer a library that has been battle-tested: validator.js in Node, email-validator in Python, EmailValidator in C#. These do the regex sniff plus DNS-aware checks (MX record present, domain exists) that you do not want to maintain by hand.

Use the regex above for client-side feedback (instant red border on a typo) and let the library or the confirmation email handle the rest. That split, fast feedback at the input, ground truth at the back end, is what every mature signup form does.

Test your email regex against real data

Regex Tester Pro gives you live matching, named groups, replacements, and reference cheatsheets in one Chrome popup. Free, private, no signup.

Add to Chrome, free

Frequently asked questions

Will this regex reject any valid email?
It will reject quoted local parts and IP-literal domains, which together account for under 0.01% of real emails. For consumer signup, it is safe.
Should I run this on the server too?
Yes, but pair it with a confirmation email and ideally an MX record check. Regex alone cannot prove the address routes.
Do I need the case-insensitive flag?
Local parts are case-sensitive per RFC, but no real provider treats them that way. Lowercase the input before storing it; the regex works with or without the i flag.
How do I allow only company emails?
Add a domain whitelist after the regex passes: split on @, check the domain against your allowed list. Do not bake the list into the regex; it is a maintenance trap.
What about emojis in email addresses?
Some providers technically support them via internationalized email (RFC 6532), but adoption is near zero. Reject and move on.

More by Peak Productivity

Free developer tools, made for the browser

Privacy-first utilities that run locally. No upload, no signup, no watermark.