Skip to main content
Authentication & Security · In-Browser Regular Expression Lab

Email Validation Regex — RFC 5322 Compliant Regular Expression

Standard, robust regular expression to validate email addresses including alphanumeric characters, dots, plus signs, and modern TLDs.

Flags:
//none
Match Found
Load Sample:
Match Inspection & Details1 match
Match #1:user@example.com

Test Samples Verification Matrix

Expected Valid Samples (Should Match)

user@example.com Pass
alex.smith+tag@company.co.uk Pass
support_dev@castov.io Pass

Expected Invalid Samples (Must Reject)

user@ Rejected (Pass)
plainaddress Rejected (Pass)
@domain.com Rejected (Pass)
user@domain.c Rejected (Pass)
Code Implementation Generator
// JavaScript / TypeScript (ES6+)
const pattern = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
const text = "user@example.com";

const isMatch = pattern.test(text);
console.log("Is Match:", isMatch);

if (isMatch) {
  const matches = text.match(pattern);
  console.log("Matches:", matches);
}

Regular Expression Token Breakdown

Matches standard email formats with username, domain name, and at least a 2-character top-level domain. Each component of the regular expression serves a distinct syntactical purpose as mapped below:

Token PatternName / ComponentFunction & Rule
^Start of stringEnsures the match starts at the beginning of the text.
[a-zA-Z0-9._%+-]+Username / Local partMatches 1 or more allowed email local-part characters.
@At symbolMatches the literal @ separator.
[a-zA-Z0-9.-]+Domain nameMatches subdomain and main domain labels.
\.DotMatches the literal period separator before the TLD.
[a-zA-Z]{2,}TLDMatches top-level domain extensions of 2 or more letters.
$End of stringEnsures no extra trailing characters exist.

Frequently Asked Questions

Does this regex support internationalized domain names (IDN)?
This regex validates ASCII domains. For full IDN / Unicode support, punycode encoding or Unicode property escapes (\p{L}) should be used.
Is RFC 5322 regex strictly recommended?
The official RFC 5322 regex is hundreds of characters long. This battle-tested standard pattern covers 99.9% of real-world emails effectively.
Browse All 40 Patterns