Free GA4 and Search Console regex tester

Test a regular expression against real page paths or search queries before you use it. Matching works the way GA4 and Search Console do, so what passes here works there.

Free, no signupGoogle's RE2 rulesReady-made patterns
Build a pattern for your siteType your own brand, pages or section and the tester writes the regex.
Your pattern For Search Console queriesYour pattern appears here as you type
Or start from an example:
Search Console matches anywhere in the URL or query and ignores capital letters. Start with (?-i) to count them.

Results

3 of 6 match
  • how to wash linen sheetsMatch
  • linen sheets queenNo match
  • What is stonewashed linenMatch
  • best linen duvet coverNo match
  • why do linen sheets pillMatch
  • linen vs cottonNo match

Checks

  • Pass: RE2 syntax Works in GA4 and Search Console.

Rather just ask the question?Connect GA4 and Search Console to Analyse8 and ask "How did non-branded searches do last month?" No filters or regex needed.Start for FreeHow AI analytics works
Key takeaways
  • GA4's "matches regex" has to match the whole value and is case-sensitive. Search Console matches anywhere in the text and ignores case.
  • Both use Google's RE2 syntax, which has no lookaheads, lookbehinds or backreferences.
  • Escape dots in domains and file types: write \. when you mean a real dot.
  • Test against real values first. A pattern that silently matches nothing looks exactly like a pattern with no data.

How to use this regex tester

  1. Choose where you'll use the pattern: Search Console, GA4 "matches regex" or GA4 "partially matches regex". Each matches differently, and the tester follows the one you pick.
  2. Build your pattern. Type words people search for, your brand names, the pages you want or a section like /blog/, and click "Test this pattern". Or start from one of the examples.
  3. Paste real values to test against, one per line. Copy them from a Search Console or GA4 report so you test what's actually in your data.
  4. Check the results and the checks. Matched values turn green with the matching part highlighted. The checks flag anything Google won't accept and the usual mistakes.
  5. Copy the pattern and paste it into your filter: "Custom (regex)" in Search Console, or "matches regex" in a GA4 report, exploration or audience.

Here is step 5 in each tool, with two of the example patterns above.

In Search Console

Search Console Performance report with the Add filter button outlined
1. In the Performance report, click Add filter.
The Add filter menu in Search Console with Query outlined
2. Choose Query to filter searches, or Page to filter page addresses.
The Query filter in Search Console set to Custom (regex), with the question searches pattern pasted in
3. Choose Custom (regex), keep Matches regex, paste your pattern and click Apply.
Search Console queries filtered by the regex, showing only questions
4. The report now shows only the searches that match: here, every question.

In GA4

The top of GA4's Pages and screens report with the Customize report pencil icon outlined
1. Open Reports, then Engagement, then Pages and screens, and click the pencil icon to customize the report.
The Customize report panel in GA4 with Add filter outlined
2. Under Report filter, click Add filter.
The Build filter panel in GA4 with Match Type set to matches regex and the value ^/blog/.+
3. Choose Page path and screen class, set Match Type to matches regex, paste your pattern and click Apply.
The GA4 Pages and screens report filtered to blog pages only
4. Only the matching pages stay in the report: here, every blog post. Click Save to keep the filter.

Why marketers use regex in GA4 and Search Console

Regular expressions let one filter do the work of many. Instead of adding ten page filters, one pattern can match every blog post, every product page or every question people search for. In Search Console they're the quickest way to split branded and non-branded searches. In GA4 they power report filters, explorations, audiences and custom channel groups.

How GA4 and Search Console read regex differently

GA4 "matches regex"GA4 "partially matches regex"Search Console
Has to matchThe whole valueAny part of the valueAny part of the value
Capital lettersCount (case-sensitive)Count (case-sensitive)Ignored (add (?-i) to count them)
SyntaxRE2RE2RE2

So blog in GA4's "matches regex" only matches a value that is exactly "blog". In Search Console the same pattern matches any URL or query that contains it. Pick the mode above that matches where you'll paste the pattern.

What RE2 doesn't support

Google uses RE2 because it's fast and safe on huge data sets. That means a few features from other regex tools won't work:

  • Lookaheads and lookbehinds, such as (?=...), (?!...), (?<=...) and (?<!...). Use the "doesn't match regex" filter option instead.
  • Backreferences, such as \1.
  • Possessive and atomic groups, such as a++ and (?>...).

This tester flags all of them, so you find out here rather than from an empty report.

Regex cheat sheet for marketers

WriteMeansExample
^Starts with^/blog/
$Ends with\.pdf$
|Orpricing|contact
.*Anything, or nothing^/blog/.*
\.A real dotanalyse8\.com
( )A group^/(blog|news)/
[ ]Any one of these characterscolou?r, [0-9]
?The thing before is optionalhttps?://
+One or more of the thing before\d+
(?i)Ignore capital letters(?i)analyse8

Ready-made regex patterns

UsePatternWhere
Question searches^(who|what|where|when|why|how)\bSearch Console queries
Branded searches (build yours with the tool above)acme[ -]?plumbing|acmeSearch Console queries
Long searches (4+ words)^(\S+\s){3,}\S+$Search Console queries
All blog posts^/blog/.+GA4 page path
A few key pages^/(pricing|contact|demo)/$GA4 page path
File downloads.*\.(pdf|docx?|xlsx?|zip)$GA4 file name or link URL
Paid mediums^(cpc|ppc|paid.*|retargeting)$GA4 session medium
Pages with URL parameters\?Search Console pages

Common regex mistakes

  • Forgetting GA4 needs a full match. blog matches nothing in GA4's "matches regex". Use .*blog.*, or choose "partially matches regex".
  • A stray | at the start or end. An empty option matches everything, so the filter quietly does nothing.
  • Spaces around |. pricing | contact looks for "pricing " with a space.
  • Unescaped dots. analyse8.com also matches "analyse8xcom". Write analyse8\.com.
  • Copying patterns from other tools. Lookaheads work in many testers but not in Google's products.
Skip the filters entirely

Ask Analyse8 which blog posts brought in signups or how non-branded searches changed this month, and get the answer with a chart. Built for agencies, freelancers and founders.

FAQ

Regex in GA4 and Search Console, answered

What regex syntax does GA4 use?

Google's RE2 syntax, the same as Search Console. It covers everything most marketers need, but not lookaheads, lookbehinds or backreferences.

Is GA4 regex case-sensitive?

Yes. "Blog" and "blog" are different in GA4. Start the pattern with (?i) to ignore capital letters. Search Console is the other way round: it ignores case unless you start with (?-i).

Why does my regex work in Search Console but not in GA4?

Usually because GA4's "matches regex" needs the pattern to match the whole value, while Search Console only needs it to match part of it. Add .* at the start and end, or use GA4's "partially matches regex".

How do I exclude something with regex?

Write the pattern for what you want to remove, then choose "doesn't match regex" (or "Custom (regex)" with "Doesn't match" in Search Console). RE2 has no negative lookahead, so that's the way to exclude.

Is there a length limit?

Search Console accepts up to 4,096 characters, and the tester warns you past that. Long lists of pages are usually easier as one shorter pattern, like ^/blog/.

Is this tool free, and do you store my patterns?

It's free with no signup. Everything runs in your browser, so your patterns and test values are never sent to or stored on our servers.

Less filtering, more answers

Connect GA4 and Search Console and ask Analyse8 what you'd otherwise build a filter for. Start free, no credit card required.

Start for FreeMore free tools