Email address regex
A local part of letters, digits and . _ % + -, an @, then a domain ending in a dot and a top-level domain of at least two letters. Copy the pattern, with 5 inputs it accepts and 5 it rejects, each checked against it at build time.
Part of developer tools.
^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$/Flags: none
Open in the testerWhat the email address regex accepts and rejects
Each result below is the output of the pattern itself, run on the input when this page was built — not a claim copied next to it. A wrong verdict stops the build.
| Input | Result | Why |
|---|---|---|
| jane.doe@example.com | Passes | the everyday shape |
| first+newsletter@example.co.uk | Passes | plus-addressing and a two-part TLD |
| a_b-c%d@mail.example.io | Passes | every allowed symbol in the local part |
| jane.doe@example | Fails | no top-level domain |
| @example.com | Fails | empty local part |
| jane doe@example.com | Fails | a space |
| jane@exa_mple.com | Fails | underscore in the domain |
| josé@example.com | Fails | non-ASCII local part, although RFC 6531 allows it |
What it wrongly lets through
These inputs match although they are not valid — checked the same way, so this list is as true as the one above.
| Input | Result | Why |
|---|---|---|
| jane..doe@example.com | Passes | consecutive dots are not a valid address |
| jane@-example.com | Passes | a domain label cannot start with a hyphen |
Limits
- A regex checks the shape of an address, not that it exists: the only proof that a mailbox works is a confirmation email that gets clicked.
- The full grammar of RFC 5322 (quoted local parts, comments, IP literals) is far larger than any pattern worth maintaining. This one refuses some legal but rare addresses and accepts a few malformed ones, which is the usual trade for a signup form.
- Internationalised addresses (non-ASCII local parts and domains) are refused. If your users write their address in their own script, validate loosely — something@something — and let the confirmation email decide.
Try it on your own input
Open this pattern in the regex tester with every example above on its own line. The link adds the g and m flags so that ^ and $ hold per line and every line is tested: the highlighted lines are the ones marked as passing here. Paste your own data in place of the examples — it is matched in your browser and never uploaded.
Other common regexes
- URL
- UUID
- IPv4 address
- Hex color
- ISO 8601 date
- 24-hour time
- Semantic version
- URL slug
- Phone number (E.164)
- US ZIP code
- MAC address
Or open the regex tester empty and bring your own pattern.