Free tool Regex tester for GA4 and RE2
Most online regex testers run JavaScript or PCRE, so a pattern that passes there can fail in Google Analytics. This one applies GA4's rules: "matches regex" must match the whole value, matching is case sensitive, and RE2 has no lookarounds or backreferences. Paste your values one per line and see which ones a filter or channel rule would catch.
- GA4 full and partial match
- RE2 compatibility warnings
- Runs locally
Test a pattern against your values
The sample is a common first attempt at an AI-assistant rule. With "matches regex" it misses www.perplexity.ai (whole-value match) and ChatGPT.com (case). Try switching to partial match, or load a preset.
Write it exactly as you would in GA4, without slashes around it.
One per line: page paths, sources, mediums, campaign names, URLs.
JavaScript mode only. Use $1, $2 or $<name> for groups.
Matched
3
Lines the pattern accepts.
Lines tested
6
Pattern length
47
GA4 report filters allow up to 250 characters.
Checks
RE2 and GA4 compatibility, plus common slips.
- OKValid RE2 for GA4: no unsupported syntax found.
- Note1 line(s) contain a match but fail "matches regex", which needs the whole value. Add .* around the pattern or use "matches partial regex".
Results
Highlighted text is what the pattern matched. Amber means it matched only part of the value.
| # | Test value | Result | Groups |
|---|---|---|---|
| 1 | chatgpt.com | Match | — |
| 2 | perplexity.ai | Match | — |
| 3 | www.perplexity.ai | Part only | — |
| 4 | gemini.google.com | Match | — |
| 5 | copilot.microsoft.com | No match | — |
| 6 | ChatGPT.com | No match | — |
Share these inputs: the values go after the # in the link, so they never reach a server.
https://tapcub.com/tools/ga4-regex-tester
Version v1.0Updated Update history
Match, part only, no match
Every line gets one of three verdicts. The middle one is where most GA4 filters go wrong.
Match
The value passes the condition as GA4 would evaluate it. In "matches regex" mode the whole value is highlighted, because the pattern had to cover all of it.
Part only
Shown in "matches regex" mode when the pattern occurs inside the value but does not cover it end to end. GA4 would exclude this value. Either widen the pattern with .* or switch to partial match.
No match
The pattern does not occur anywhere in the value, including differences in letter case. GA4 regex is case sensitive, so chatgpt does not match ChatGPT.
Checks
"Not RE2" means GA4 will refuse to save the pattern or will not match as expected. Warnings flag patterns that are valid but usually wrong, such as an unescaped dot or a trailing pipe.
Results run on your browser's JavaScript engine after translating RE2-only syntax. For the RE2 subset GA4 supports, the two engines agree; anything flagged "Not RE2" may behave differently in GA4.
Test before you save the filter
A broken channel rule silently misfiles traffic from the day you save it. Three steps catch most of it.
-
1
Pick the match type you will use
"Matches regex" for custom channel group conditions and exact report filters; "matches partial regex" where GA4 offers it and you only need a fragment to appear.
-
2
Paste real values
Export the dimension (Session source, Page path, Campaign) from the report and paste a few dozen values, including ones that must not match.
-
3
Fix until the checks are clean
Every intended value shows Match, every other value shows No match, and the checks show no "Not RE2" lines. Then copy the pattern into GA4.
How GA4 evaluates a regular expression
Google Analytics uses Google's RE2 engine. RE2 guarantees linear-time matching, and pays for it by leaving out features that need backtracking.
- Full match by default: "matches regex" behaves as if the pattern were wrapped in
^(?:…)$ - Case sensitive: Google's help states regex filters are case sensitive
- Report filters accept regular expressions of up to 250 characters
| Feature | RE2 (GA4) | JavaScript |
|---|---|---|
^ $ . * + ? | ( ) [ ] {n,m} | Yes | Yes |
\d \w \s \b | Yes (ASCII) | Yes |
Lazy quantifiers *? +? | Yes | Yes |
| Named groups | (?P<n>…) and (?<n>…) | (?<n>…) |
Leading (?i) flag | Yes | No (use the i flag) |
| Lookahead / lookbehind | No | Yes |
Backreferences \1 | No | Yes |
| Possessive / atomic | No | No |
| Repeat count above 1000 | No | Yes |
The sample, under each match type
The default pattern chatgpt\.com|perplexity\.ai|gemini\.google\.com against six Session source values.
| Value | matches regex | matches partial regex | Why |
|---|---|---|---|
chatgpt.com | Match | Match | Whole value is one alternative |
perplexity.ai | Match | Match | Same |
www.perplexity.ai | No match | Match | The www. prefix is outside the pattern |
gemini.google.com | Match | Match | Same |
copilot.microsoft.com | No match | No match | Not in the pattern |
ChatGPT.com | No match | No match | Case sensitive |
A sturdier version for full match is ^(.*\.)?(chatgpt\.com|perplexity\.ai|gemini\.google\.com)$: it allows any subdomain and nothing else. The AI referral regex builder produces this form for the whole list of assistants.
Why GA4 regex filters fail
Four slips account for most broken filters and channel rules.
Expecting a partial match
blog with "matches regex" only matches a value that is exactly "blog". Use .*blog.* or ^/blog/ with partial match.
Forgetting case
Campaign names and UTM values are stored as sent. Spring_Sale and spring_sale are different values to GA4.
Pasting a JavaScript pattern
Lookaheads such as ^(?!.*test) are popular in JS answers online and invalid in RE2. Use a "does not match" condition instead.
A trailing pipe
a|b| includes an empty alternative, which matches every value in partial mode. Google's help warns against it.
Channels classified for you
TapCub sorts every visit into search, social, AI assistants, email, paid, referral or direct as it arrives, so you need far fewer regex rules to see where traffic comes from.
Sources with AI assistants built in
ChatGPT, Perplexity, Claude, Gemini, DeepSeek, Kimi and others get their own channel without any custom rule.
Learn moreMarketing analytics
Channel ROI and attribution on the same visitor data, with UTM campaigns side by side.
Learn moreSegments
Rule-based and RFM segments in product analytics, updated continuously, so groups are defined once instead of re-typed as filters.
Learn moreGA4 regex questions
Still have a question?
Chat with the team behind TapCub — we usually reply within a few hours on business days.
Does GA4 "matches regex" require a full match?
Yes. Google's help says GA4 regex is full regex by default: the pattern has to match the entire value. San Francisco matches only "San Francisco", while .*San Francisco.* also matches "South San Francisco".
What is the difference between "matches regex" and "matches partial regex"?
"Matches regex" needs the whole value to fit the pattern; "matches partial regex" is satisfied if the pattern occurs anywhere in the value. Report filters offer both, plus "does not match regex" and "does not match partial regex". Google's own channel-group example uses "matches regex".
Is GA4 regex case sensitive?
Yes, regex filters in GA4 reports are case sensitive. Write patterns in the case the data is stored in, or cover both forms, such as [Ss]pring.
Which regex syntax does GA4 use?
Google's RE2. It supports the common syntax — anchors, groups, character classes, quantifiers, alternation — but not lookahead, lookbehind, backreferences, possessive quantifiers or atomic groups.
Is there a length limit for GA4 regex?
Google's help on report filters states that regular expressions are limited to 250 characters. The tester shows the length and warns above that.
How do I exclude values without a negative lookahead?
Add a second condition with "does not match regex" (in filters) or an exclusion condition, instead of writing (?!…), which RE2 does not support.
Does this tester work for BigQuery or Looker Studio too?
Both also use RE2, so the compatibility checks apply. Matching functions differ: BigQuery REGEXP_CONTAINS is a partial match, so use the partial mode or add anchors yourself.
Are my patterns or values uploaded?
No. Everything runs in your browser. Short patterns and values go into the share link after the #, which is never sent to a server.
Update history
New features, fixes and data refreshes for this tool, newest first.
-
· v1.0
LaunchedFirst release.
Missing something or found an error? Tell us — requests that come up often go into the next update. All tool updates
See channels without writing regex
TapCub classifies search, social, AI assistants, email and paid traffic on arrival, and keeps bots out of the numbers.