Developer

Encoders, converters & dev utilities

12 tools
Developer · Regex Cheat Sheet & Common Patterns

Regex to Match an Email Address (JavaScript)

The pragmatic pattern for matching an email address is ^[^\s@]+@[^\s@]+\.[^\s@]+$ — one or more characters that are not whitespace and not @, then an @, then a domain, a dot and a TLD, with no spaces anywhere. This is deliberately loose: a fully RFC-5322-compliant email regex is thousands of characters long, still rejects some valid addresses and accepts some invalid ones, so it is not worth chasing. The industry-standard approach is to use a simple shape check like this to catch obvious typos, then confirm the address is real by sending a verification email. This pattern is JavaScript-flavour and is verified in our CI test suite against real examples and counter-examples. Copy it, test your own strings in the live in-browser tester, and never treat a regex pass as proof the mailbox exists. Free, no login.

Quick answer

Pattern: ^[^\s@]+@[^\s@]+\.[^\s@]+$ (JavaScript RegExp, no flags needed)

Open the full Regex Cheat Sheet & Common Patterns

Frequently asked questions

What is a good regex to validate an email address?

A pragmatic, widely used pattern is ^[^\s@]+@[^\s@]+\.[^\s@]+$: one or more non-space, non-@ characters, an @, a domain, a dot and a TLD. It rejects obvious mistakes like "abc", "a@b" or an address with a space, while accepting normal addresses such as [email protected]. Do not try to write a fully RFC-5322-compliant regex — it is enormous and still imperfect. Use this shape check and then verify the address really works by emailing a confirmation link.

Why not use a stricter email regex?

Because email addresses are far more permissive than most people expect — quoted local parts, plus-addressing, internationalised domains and more are all legal. A regex strict enough to reject every invalid address would also reject valid ones and be unmaintainable. The correct validation of an email address is to send it a message and confirm the recipient clicks the link. A loose regex like ^[^\s@]+@[^\s@]+\.[^\s@]+$ is only there to catch typos before you attempt delivery.

Related Regex Cheat Sheet & Common Patterns pages