Regex for Email Validation

Validate email addresses with this regex pattern. Matches standard email formats including local part, domain, and TLD. Free online regex tester tool.

Regular Expression

/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/i

Token Breakdown

TokenDescription
^Anchors at the start of the string (or line in multiline mode)
[a-zA-Z0-9._%+-]Character class — matches any one of: a-zA-Z0-9._%+-
+Matches the preceding element one or more times (greedy)
@Matches the literal character '@'
[a-zA-Z0-9.-]Character class — matches any one of: a-zA-Z0-9.-
+Matches the preceding element one or more times (greedy)
\.Matches a literal dot
[a-zA-Z]Character class — matches any one of: a-zA-Z
{2,}Matches 2 or more times
$Anchors at the end of the string (or line in multiline mode)

Detailed Explanation

This regex validates standard email address formats. Here is a token-by-token breakdown:

^ — Anchors the match at the start of the string, ensuring nothing precedes the email.

[a-zA-Z0-9._%+-]+ — Matches the local part (before the @). It allows one or more letters (upper or lowercase), digits, dots, underscores, percent signs, plus signs, and hyphens. This covers most valid email local parts.

@ — Matches the literal at-sign separating the local part from the domain.

[a-zA-Z0-9.-]+ — Matches the domain name portion. It allows letters, digits, dots (for subdomains), and hyphens. The plus quantifier requires at least one character.

. — Matches a literal dot before the top-level domain. The backslash escapes the dot so it is not treated as the wildcard metacharacter.

[a-zA-Z]{2,} — Matches the top-level domain (TLD), requiring at least two letters. This accommodates TLDs like .com, .org, .info, and newer ones like .technology.

$ — Anchors the match at the end of the string, ensuring nothing follows the email.

The i flag makes the match case-insensitive, though the character classes already include both cases for clarity. This pattern works well for most real-world email validation but does not cover every edge case in RFC 5322.

Example Test Strings

InputExpected
user@example.comMatch
first.last+tag@sub.domain.orgMatch
admin@localhostNo Match
user@@example.comNo Match
name@domain.co.ukMatch

Try It — Interactive Tester

//i
gimsuy
No matches found.
Pattern: 48 charsFlags: iMatches: 0

Ctrl+Shift+C to copy regex

Customize this pattern →