Advertisement

Pattern library / Validation

Practical Email Validation Regex

The full RFC 5322 email grammar is thousands of characters and still wrong at the edges. What you actually need in forms, log filters and analytics segments is a practical pattern: one @, no spaces, a dot-separated domain — roughly 30 characters, valid RE2, and honest about what it does not check.

The pattern
^[^\s@]+@[^\s@]+\.[^\s@]{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
ada@example.comMatchstandard addressTry →
first.last+tag@sub.domain.coMatchplus-tag and subdomainTry →
no-at-sign.example.comNo matchmissing @Try →
spaces here@example.comNo matchno whitespace allowedTry →
user@domainNo matchTLD missing (needs dot + 2+)Try →
user@.comNo matchempty domain labelTry →

Where to use it

JavaScript (HTML input)

const re = /^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/;
re.test('ada@example.com'); // true
// <input type="email" pattern="[^\s@]+@[^\s@]+\.[^\s@]{2,}">

Python

import re
EMAIL = r'^[^\s@]+@[^\s@]+\.[^\s@]{2,}$'
bool(re.fullmatch(EMAIL, 'ada@example.com'))

BigQuery / GA4 (RE2)

REGEXP_CONTAINS(user_email, r'^[^\s@]+@[^\s@]+\.[^\s@]{2,}$')

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

Is this email regex RFC 5322 compliant?

No — and that is intentional. It accepts every address people actually use and rejects the garbage. Full RFC compliance requires a parser, not a regex.

Why does user@domain fail?

The pattern requires a literal dot followed by at least two characters (the TLD part). Real public domains always have it; remove \.[^\s@]{2,} if you accept intranet names.

Does this work in GA4 or BigQuery?

Yes — character-class negation, @ and \ . are all RE2-valid. For long email fields prefer BigQuery REGEXP_CONTAINS over GA4 filters.

URL Regex — Match http/https Links (Practical) · Slug Regex — Match lowercase-hyphen URL Slugs · Quoted String Regex — Match "..." and '...'

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.