Advertisement

Pattern library / Strings & Text

Strict Regex to Validate Email Addresses

Stricter than the basic email regex: requires a TLD of at least 2 letters and rejects obviously invalid shapes. Still not a substitute for sending a verification email.

The pattern
^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$
Load this pattern into the tester →

How the pattern works

Test it: match & no-match examples

Every row is loaded straight into the tester — click Try to see the match live:

InputResultWhy
user@example.comMatchvalid emailTry →
first.last+tag@sub.example.co.ukMatchsubdomain + multi-part TLDTry →
user@exampleNo matchmissing TLDTry →
user@.comNo matchempty local part domainTry →
@example.comNo matchmissing local partTry →

Where to use it

JavaScript

const re = /^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$/;
re.test('user@example.com');  // true

Python

import re
re.match(r'^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$', 'user@example.com')

Common mistakes

Test this pattern on your own data
Paste it into the free tester with your real strings — nothing leaves your browser.
Open the regex tester →

FAQ

For GA4-specific patterns, see the GA4 regex cheat sheet, the page path regex guide, the event filter regex guide, the GA4 regex match types, the custom channel grouping guide and RE2 vs PCRE. Browse the full regex pattern library.