elefcode

Regex pattern

Email Regex — free online tester

A practical email-validation regex that catches the 99% case without choking on every RFC edge case.

The pattern

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

How it works

Email addresses follow a deceptively complex spec (RFC 5322). A full-coverage regex is hundreds of characters long and still gets corner cases wrong. In practice, the pattern below catches every email format you'll see in production input — local part with letters, digits, dots, underscores, percent signs, plus, hyphens; @ separator; domain with one or more labels; TLD of 2 or more letters.

When to use it

  • Frontend form validation before sending data to the server
  • Extracting email addresses from log files or scraped text
  • Cleaning up CSV / spreadsheet imports
  • Quick sanity checks in scripts and one-off shell commands

Tip

Use this as a first-pass filter, then verify the address actually exists by sending a confirmation email. Regex can't tell you the inbox is real.

Try it on this input

Contact us at [email protected] or [email protected].
Customers wrote in: [email protected], [email protected], [email protected]
Bad ones: not.an.email, [email protected], @nodomain.org, plain text only

What this pattern doesn't catch

  • Won't flag valid but unusual addresses with quoted local parts ("john doe"@example.com)
  • Doesn't enforce IDN (internationalised) domains like 北京.中国
  • Treats single-letter TLDs as invalid (none exist today, but the spec allows them)

More regex patterns