TapCub is live — analytics, insights and live chat, free on one platform

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
Tester

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.

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 valueResultGroups
1chatgpt.comMatch—
2perplexity.aiMatch—
3www.perplexity.aiPart only—
4gemini.google.comMatch—
5copilot.microsoft.comNo match—
6ChatGPT.comNo match—
Runs entirely in your browser. Nothing you type here is uploaded or stored by TapCub.

Share these inputs: the values go after the # in the link, so they never reach a server.

Version v1.0Updated Update history

Read the result

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.

How to use it

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. 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. 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. 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.

Rules

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
RE2 compared with JavaScript regular expressions
FeatureRE2 (GA4)JavaScript
^ $ . * + ? | ( ) [ ] {n,m}YesYes
\d \w \s \bYes (ASCII)Yes
Lazy quantifiers *? +?YesYes
Named groups(?P<n>…) and (?<n>…)(?<n>…)
Leading (?i) flagYesNo (use the i flag)
Lookahead / lookbehindNoYes
Backreferences \1NoYes
Possessive / atomicNoNo
Repeat count above 1000NoYes
Worked example

The sample, under each match type

The default pattern chatgpt\.com|perplexity\.ai|gemini\.google\.com against six Session source values.

Results of the sample pattern with full and partial matching
Valuematches regexmatches partial regexWhy
chatgpt.comMatchMatchWhole value is one alternative
perplexity.aiMatchMatchSame
www.perplexity.aiNo matchMatchThe www. prefix is outside the pattern
gemini.google.comMatchMatchSame
copilot.microsoft.comNo matchNo matchNot in the pattern
ChatGPT.comNo matchNo matchCase 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.

Common mistakes

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.

FAQ

GA4 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.

Changelog

Update history

New features, fixes and data refreshes for this tool, newest first.

  1. · 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 your data clearly. Find your growth.

Every click, backed by data. Install one line of code and see your first numbers in a minute.

No credit card · Free plans for analytics and chat · Cookieless analytics