GA4’s filters, custom channel groups, and Explorations all accept regular expressions, but they run on Google’s RE2 engine specifically — which supports most common syntax but not lookahead or lookbehind assertions, a gap that trips up anyone copying a pattern from a general-purpose regex tester. This guide covers a few patterns that actually work.
RE2 Basics and What’s Missing
Standard character classes, quantifiers, and anchors all work as expected (.*, \d, ^, $), but RE2 explicitly does not support lookahead ((?=...)) or lookbehind ((?<=...)), which are common in patterns pulled from general regex documentation or ChatGPT-generated examples that don’t account for GA4’s specific engine. Test any pattern in GA4’s own filter or channel-group UI before relying on it — a pattern that validates on a general regex tester can still fail silently in GA4 if it uses an unsupported feature.
Working Patterns Worth Saving
To match a blog section regardless of trailing slash: ^/blog/schema/.*. To match any of several known AI referrer domains in a channel group source rule: chatgpt\.com|perplexity\.ai|gemini\.google\.com. To exclude a query string entirely when matching a page path: ^/blog/[^?]*$. Keep a running list of these in a shared document as you build them — regex patterns for channel groups and filters get reused across properties more often than most teams expect.
- GA4 uses Google’s RE2 regex engine, which does not support lookahead or lookbehind assertions.
- Always test a pattern directly in GA4’s own UI — a pattern valid elsewhere can fail silently here.
- A small library of working patterns (blog sections, AI referrer domains, path-without-query) covers most common GA4 use cases.
Frequently Asked Questions
Does GA4 support standard regex syntax?
Mostly — it uses Google’s RE2 engine, which supports common character classes, quantifiers, and anchors, but not lookahead or lookbehind assertions.
Why did a regex pattern from a tutorial fail in GA4?
Most likely it used a lookahead or lookbehind assertion, which RE2 doesn’t support. Simplify the pattern to avoid those constructs.
Where in GA4 can I use regex?
Filters, custom channel group rules, audience definitions, and Explorations dimension filters all accept RE2 regex patterns.
The Bottom Line
Regex in GA4 is powerful but engine-specific — keep a saved library of patterns that are known to work in GA4’s actual UI rather than trusting patterns validated elsewhere.
Further reading & sources
- RE2 regex syntax reference — Google/GitHub
See how your site actually shows up in AI search. An AI visibility audit maps where you’re cited, where you’re invisible, and what to fix first — in plain English.
Get your AI visibility auditTry the free SEO tools →
Prefer self-serve? The interactive checklists turn guides like this one into a working to-do list.
Keep reading in GA4 & SEO Analytics: The Complete Guide
Get one email when something genuinely changes
AI search moves fast and most of it is noise. We send one short email when a real shift is worth your time. Unsubscribe anytime.
Published by Plain Intelligence — practical AI SEO, GEO, and technical SEO, documented in plain English. About Plain Intelligence →
↑ Back to GA4 & SEO Analytics: The Complete Guide · Explore all articles · Free tools & resources · Glossary