Back to Blog
GA4 Regex Filters: Pattern Matching for Reports and Explorations
Analytics
Oct 14, 2025
Ludde

GA4 Regex Filters: Pattern Matching for Reports and Explorations

A practical Regular expressions (Regex) guide for GA4 reports. Filter multiple pages in a single GA4 exploration and match complex URL parameter strings.

GA4 supports regex (regular expressions) in report filters, explorations, and audiences — but the documentation is thin, the syntax is inconsistent across features, and many patterns that worked in Universal Analytics simply don't work in GA4. Here's your definitive reference.

Where Regex Works in GA4

  • Explorations: Filter rows using "matches regex" condition ✅
  • Custom report filters: Available via the "matches regex" operator ✅
  • Audiences: Regex conditions on dimensions ✅
  • Standard report comparisons: Limited — uses "contains" or "exactly matches" only ❌
  • Segments (Explorations): Full regex support ✅

GA4 Regex Syntax Rules

GA4 uses RE2 regex syntax (not PCRE). Key differences:

  • No lookaheads or lookbehinds ((?=...) and (?<=...) don't work)
  • No backreferences (\1 not supported)
  • Regex is case sensitive by default — use (?i) prefix for case-insensitive
  • Partial match by default — regex matches any substring. Use ^ and $ for full match

Copy-Paste Regex Patterns

Match multiple page paths:

^/(blog|resources|guides)/

Matches any page starting with /blog/, /resources/, or /guides/.

Exclude specific pages:

^/(?!admin|internal|staging)

⚠️ Warning: Negative lookahead doesn't work in RE2. Instead, use the "does not match regex" comparison operator with: ^/(admin|internal|staging)

Match UTM campaign patterns:

(?i)^(spring|summer|fall|winter)_sale_2025$

Case-insensitive match for seasonal campaign names.

Match product category pages:

^/products/[^/]+/?$

Matches /products/shoes/, /products/bags, but NOT /products/shoes/nike/.

Match localized pages:

^/(en|sv|de|fr)/

Matches pages with language prefixes.

Using Regex in Explorations

  1. Create a new Free-form Exploration
  2. Add your dimension (e.g., "Page path")
  3. Click the filter icon on the dimension
  4. Change the match type to "matches regex"
  5. Enter your regex pattern
  6. Apply — the exploration updates to show only matching rows

Using Regex in Audience Definitions

When building GA4 audiences, you can use regex to create dynamic segments:

  1. Go to Admin → Audiences → New Audience → Create a Custom Audience
  2. Add a condition on a dimension (e.g., Page path)
  3. Set the operator to "matches regex (case sensitive)"
  4. Enter your pattern

Example: Create an audience of users who visited any product page: ^/products/

Common Regex Mistakes in GA4

  • Forgetting anchors: blog matches "/blog" but also "/blogging-tips". Use ^/blog/ for precision.
  • Not escaping dots: google.com matches "googleXcom" too. Use google\.com.
  • Using lookaheads: RE2 doesn't support them. Use separate filters with "does not match regex" instead.
  • Over-complicating patterns: Start simple. Test with a few known URLs before applying to reports.

Filter Accuracy Check

NiceLookingData verifies your GA4 data filters and configurations to ensure you're capturing — and not accidentally excluding — the data you need. Run a free audit.

Free Tool

Run a free GA4 audit on your property

Connect your Google Analytics 4 property. Our auditor runs 36+ checks and gives you an instant health score with a plain-English action plan.

Thanks for reading!