Looker Studio Regex — Filters and REGEXP_MATCH That Actually Work
Looker Studio speaks regex in three places: chart-level filters (Regexp Match / Regexp Contains), calculated fields (REGEXP_MATCH, REGEXP_CONTAINS, REGEXP_EXTRACT, REGEXP_REPLACE) and the advanced filter control. All three run Google’s RE2 engine — and the two rules that decide every result are the exact opposite of what people copy over from other tools: Regexp Match and REGEXP_MATCH match the entire value, and everything is case-sensitive unless you add (?i). This page is every claim below verified against Google’s own documentation, with each verdict executed before publish.
TL;DR: REGEXP_MATCH(field, 'A') on ABC123 is false — it must match the whole value; REGEXP_CONTAINS on the same pair is true. So ^/blog/ under Regexp Match matches nothing on /blog/post-a (add .*). Case: C[a-z]* misses chrome — prepend (?i). Engine: RE2, so no lookahead — the negative lives in the filter’s Exclude option, never in a (?!...).
Where regex lives in Looker Studio
Same pattern, four surfaces — pick the row that matches where you’re stuck:
| Surface | Where | What to write | Match behavior |
|---|---|---|---|
| Chart / page / report filter | Select chart → Add a filter → condition dropdown | Regexp Match or Regexp Contains + pattern |
Match = whole value; Contains = anywhere in the value |
| Calculated field | Add a field → formula | REGEXP_MATCH / REGEXP_CONTAINS / REGEXP_EXTRACT / REGEXP_REPLACE |
MATCH = whole value; CONTAINS = anywhere; EXTRACT = first substring |
| Advanced filter control | Insert → Control → Advanced filter (style: search type) | Set search type to Regexp; viewers type the pattern |
Viewer-entered pattern; same RE2 rules |
| Segments & goal steps | Per Google’s regex docs: “create segments, filters, or goal steps that match a URI” | ^/mens/ style path patterns |
Same RE2 patterns; ^/mens/ matches the /mens/ directory |
Google’s docs also spell the operators “RegExp Match” and “RegExp Contains” in some places — same two conditions, whichever spelling your build shows.
REGEXP_MATCH semantics: the full-match rule
Google’s function page defines it in one line: REGEXP_MATCH “returns true if the target value exactly matches the regular expression pattern.” And the REGEXP_CONTAINS page states the relationship explicitly: REGEXP_MATCH “will only match the entire value by default”, so REGEXP_CONTAINS(field, "pattern") is functionally equivalent to REGEXP_MATCH(field, ".*pattern.*"). Every row below is from Google’s example tables — and was re-executed here before publish:
| Formula | Value | REGEXP_MATCH (whole value) | |
|---|---|---|---|
REGEXP_MATCH(field, 'A') |
ABC123 |
false — one letter can’t cover six | Try → |
REGEXP_MATCH(field, 'A.*') |
ABC123 |
true — anchored by the rule, consumed by A.* |
Try → |
REGEXP_MATCH(name, '[a-zA-Z].*') |
Sam |
true | Try → |
REGEXP_MATCH(name, '[a-zA-Z].*') |
$am |
false — starts with $ (the am inside is why Contains would say true) |
Try → |
REGEXP_MATCH(country, '(USA|Canada|Mexico)') |
Canada |
true | Try → |
REGEXP_MATCH(country, '(USA|Canada|Mexico)') |
Brazil |
false | Try → |
GA4 patterns port almost directly — that’s the good news. GA4’s matches regex is also a full match, also case-sensitive, also RE2 (the full map is in GA4 regex match types). The patterns that do not port are the Search Console ones: that tool matches anywhere and ignores case by default — the opposite defaults, same engine, in the Search Console regex guide. BigQuery has no REGEXP_MATCH at all; its decision lives between REGEXP_CONTAINS (partial) and REGEXP_EXTRACT (first substring) — see the BigQuery comparison.
REGEXP_EXTRACT is partial by design — it returns the first matching substring, so it never needs the full-match treatment:
| Formula | Value | Result | |
|---|---|---|---|
REGEXP_EXTRACT(URL, '^https://[^/]+/([^/]+)/') |
https://support.google.com/looker-studio/answer/7064476 |
looker-studio |
Try → |
REGEXP_EXTRACT(URL, '^https://[^/]+/([^/]+)/') |
https://cloud.google.com/bigquery/docs/reference/standard-sql/string_functions |
bigquery |
Try → |
Filter operator table: same pattern, different rows
The filter condition dropdown offers Regexp Match (whole value) and Regexp Contains (anywhere) as separate conditions — plus Equal to (=), Contains, Starts with, In and Is Null. Google’s own documentation pairs C[a-z]* against both regex conditions to show the difference. Each verdict cell has its own Try link: Match loads the pattern anchored to reproduce the whole-value rule, Contains loads it as a plain scan:
| Pattern | Value | Regexp Match | Regexp Contains |
|---|---|---|---|
C[a-z]* |
Chromebook |
matchTry → | matchTry → |
Google Chrome |
no match — starts with GTry → |
match — Chrome sits insideTry → |
|
(?i)C[a-z]* |
chrome |
matchTry → | match — (?i) covers lowercaseTry → |
Google Chrome |
no match — still must start with CTry → | matchTry → | |
.*c$ |
organic |
match — Google’s own filter exampleTry → | matchTry → |
cpc |
match — the doc’s example includes itTry → | matchTry → | |
brand |
no match — no c at the endTry → |
no matchTry → |
Why two Try links per row: the tester scans for matches anywhere in the string (Contains behavior). Match verdicts above load the pattern wrapped in ^(?:...)$ so the tester reproduces Looker Studio’s whole-value rule — that wrapping is the only difference, and it is exactly the rule this page is about. (?i) rows load with the case-insensitive flag, since the JavaScript tester cannot compile inline flags; details in RE2 vs PCRE.
In vs regex: In takes a comma-separated list of complete values and is case-sensitive — Google’s operators doc points you at regex for everything else: partial values and case-insensitive matching. Write google|bing under Regexp Contains instead of listing spellings under In.
Copy-paste recipes
Every verdict executed before this page went live. Each Try link loads pattern + sample data into the tester with Looker Studio’s case-sensitive default (recipe rows that say (?i) load with the flag applied).
1. Group sources under Regexp Match
Filter panel → Source → Regexp Match → this pattern keeps organic search engines and nothing else:
| Pattern | Value | Verdict | |
|---|---|---|---|
^(google|bing|duckduckgo|yahoo)$ |
google |
match — kept | Try → |
google ads |
no match — whole-value rule rejects it (use Contains if you want both) | Try → |
2. URL cleanup — the ^/blog/ trap
Path prefixes are where the full-match rule bites hardest. Under Regexp Match, ^/blog/ demands the value be exactly /blog/ and rejects every article under it — the same trap GA4 users hit on page_path (solved there in the page path regex guide). Two working versions:
| Pattern | Value | Regexp Match | |
|---|---|---|---|
^/blog/ |
/blog/post-a |
no match — the trapTry → | under Contains it would match — see below |
/blog/ |
match — exact directory onlyTry → | rarely what you want | |
^/blog/.* |
/blog/post-a |
match — fix: trailing .*Try → |
or keep ^/blog/ and switch to Contains |
/news/post |
no match — correctly rejectedTry → |
3. Language detection from GA4 campaign names
Google’s own calculated-field example: a campaign dimension packed as ... | US | en | Hybrid | ... — pipe-delimited, so the pattern matches the token between pipes:
| Pattern | Value | Verdict | |
|---|---|---|---|
.*\|\s*en\s*\|.* |
GA Demo | DR | apontes | NA | US | en | Hybrid | AW SEM |
match — CASE returns “English” | Try → |
GA Demo | DR | apontes | NA | CA | es | Hybrid | AW SEM |
no match — falls through to the ELSE |
Try → |
Full formula shape: CASE WHEN REGEXP_MATCH(Campaign, R".*\|\s*en\s*\|.*") THEN "English" ... END — the R prefix is the raw-string escape fix from the gotchas below.
4. Channel bucketing
Paid-channel rollup as a calculated field or filter — again Regexp Match, again whole-value:
| Pattern | Value | Verdict | |
|---|---|---|---|
^(cpc|cpm|cpa|ppc)$ |
cpc |
match — bucketed as Paid | Try → |
organic |
no match — stays out of the Paid bucket | Try → |
5. Tracking-parameter leak (Regexp Contains only)
A full URL can never satisfy a whole-value pattern that only describes its tail — this one must run under Regexp Contains:
| Pattern | Value | Verdict | |
|---|---|---|---|
[?&](utm_|gclid|fbclid) |
https://example.com/landing?gclid=abc |
match (Contains) — canonicalization candidate | Try → |
https://example.com/landing |
no match — clean URL stays in | Try → |
Five ways a Looker Studio regex silently misbehaves
- The full-match rule (the big one).
Regexp MatchandREGEXP_MATCHcover the entire value —^/blog/fails on/blog/post-a,Afails onABC123. Fix: trailing.*, or theRegexp Containscondition, or the doc-equivalent rewriteREGEXP_CONTAINS(field, "pattern"). (Search Console users have the mirror-image problem — there everything is partial by default: Search Console regex.) - Escaping eats your backslashes — in calculated fields. A formula string consumes one level before the regex engine sees it, so write
\\dfor a digit, or skip the whole dance with a raw string:R"\d+"(Google’s documented fix; their example isREGEXP_MATCH(GotStars, "\\*")matching a literal*). Filter condition value boxes take the pattern as-is — Google’s filter examples type.*c$with no doubling. Two surfaces, two rules. - Case-sensitive by default.
C[a-z]*misseschrome,Chromehits butchromedoesn’t. Fix: prepend(?i)— Google’s own filter example does exactly this. This is the same default as GA4 and the opposite of Search Console ((?-i)is RE2-only and won’t compile in JavaScript testers — RE2 vs PCRE). - Nulls never match a regex. A pattern condition on a null dimension is not a match — it needs the separate
Is Nullcondition. Empty string""and null are different things in Looker Studio’s operator model (null propagates through operators;""is a value a pattern like^$can match). - No lookahead, ever. RE2 rejects
(?!...),(?<=and\1— in filters, calculated fields and segments alike. The pattern won’t error in your JS-based editor; it fails silently in Looker Studio. Use the filter’s Exclude mode with a positive pattern instead (GA4’s does not match regex works the same way — catalogued in RE2 vs PCRE).
FAQ
What regex syntax does Looker Studio use?
RE2 — the same engine family as GA4, BigQuery and Search Console. Looker Studio regex is case-sensitive by default; prepend (?i) to a pattern to make it case-insensitive. Lookahead, lookbehind and backreferences are rejected outright — the full construct-by-construct mapping is in RE2 vs PCRE.
What is the difference between REGEXP_MATCH and REGEXP_CONTAINS?
REGEXP_MATCH matches the entire value — REGEXP_MATCH(field, 'A') on ABC123 is false. REGEXP_CONTAINS matches anywhere — the same call is true. Google documents them as equivalent: REGEXP_CONTAINS(field, "pattern") behaves like REGEXP_MATCH(field, ".*pattern.*"). In the filter panel the same two behaviors are the Regexp Match and Regexp Contains conditions.
Why does my Looker Studio regex filter return no rows?
Almost always the full-match rule: Regexp Match / REGEXP_MATCH require the pattern to cover the whole value, so ^/blog/ matches nothing on /blog/post-a. Add a trailing .*, or switch the condition to Regexp Contains. Two other silent killers: null values never match a regex (add an Is Null condition), and (?i) must be inside the pattern — there is no case toggle in the dropdown.
How do I make a regex case-insensitive in Looker Studio?
Prepend the inline flag: (?i)C[a-z]*. Google’s filter documentation uses it directly — Regexp Contains with (?i)C[a-z]* matches chrome, Chrome, Chromebook and Google Chrome. The flag works the same in calculated fields and filter conditions. (JavaScript-based testers can’t compile (?i) inline — load the pattern with the i flag instead, as this page’s Try links do.)
How do I escape backslashes in a calculated field?
Double them — \\d for a digit — because the formula string consumes one level before the regex engine runs. Or use the raw-string prefix R (R"\d+") and write the pattern exactly once, which is what Google’s own examples do. Filter condition value boxes are different: they take the pattern as-is, no doubling (Google’s filter examples type .*c$ directly).
Can I use lookahead in Looker Studio?
No. Looker Studio runs RE2, which does not implement lookahead, lookbehind or backreferences — in filters, calculated fields or segments. The pattern may even work in your code editor first (JavaScript accepts it); it silently fails in Looker Studio. Use the filter’s Exclude option with a positive pattern instead. Every RE2-illegal construct and its replacement is mapped in RE2 vs PCRE.
Related on RegexLab: RE2 vs PCRE (every construct Looker Studio rejects and its fix), GA4 regex match types (the same full-match rule on the GA4 side — why GA4 patterns port), Search Console regex (the opposite defaults, same engine), GTM regex trigger (partial-match trigger filters, same engine), BigQuery REGEXP_EXTRACT vs REGEXP_CONTAINS (the same RE2 semantics in SQL), and the regex pattern library for ready-made patterns beyond Google tools.