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 Pattern | Name / Component | Function & Rule |
|---|---|---|
| ^ | Start of string | Ensures the match starts at the beginning of the text. |
| [a-zA-Z0-9._%+-]+ | Username / Local part | Matches 1 or more allowed email local-part characters. |
| @ | At symbol | Matches the literal @ separator. |
| [a-zA-Z0-9.-]+ | Domain name | Matches subdomain and main domain labels. |
| \. | Dot | Matches the literal period separator before the TLD. |
| [a-zA-Z]{2,} | TLD | Matches top-level domain extensions of 2 or more letters. |
| $ | End of string | Ensures no extra trailing characters exist. |
Frequently Asked Questions
Does this regex support internationalized domain names (IDN)?
Is RFC 5322 regex strictly recommended?
Related Regular Expressions
Browse All 40 PatternsAuthentication & Security
Alphanumeric Username
Standard web application username policy: 3 to 20 characters, starting with a letter, allowing underscores.
/^[a-zA-Z][a-zA-Z0-9_]{2,19}$/Test regex
Network & Web
HTTP & HTTPS URL Validation
Matches fully qualified URLs starting with http:// or https://, including subdomains, paths, ports, and query parameters.
/^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}(?:\.[a-zA-Z0-9()]{1,6})?(?::[0-9]{1,5})?\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$/iTest regex
Network & Web
Domain Name Matcher
Validates Fully Qualified Domain Names (FQDN) adhering to DNS hostname specification (RFC 1035).
/^(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/Test regex