Looker Studio REGEXP_CONTAINS() Guide

When you need to search for patterns inside your data — not just exact matches — REGEXP_CONTAINS() is one of the most powerful functions you can use inside Looker Studio.
If you want a guide on how to “exact match” a pattern, check out our guide on REGEXP_MATCH().
In this guide, you’ll learn exactly how REGEXP_CONTAINS() works, how to use it, real-world examples, common mistakes to avoid, and troubleshooting tips. Plus: copy-paste regex templates you can use immediately.
Let’s dive in. 👇
What is REGEXP_CONTAINS()?
REGEXP_CONTAINS() checks whether a piece of text matches a specific pattern.
- REGEXP = Regular Expression, a method for describing search patterns in text.
- CONTAINS = Checking if a pattern exists somewhere inside a text value.
Syntax
REGEXP_CONTAINS(X, regular_expression)
Where:
X
= the text field you want to check.regular_expression
= the pattern you are searching for.
Basic Examples
🔹 Check if a product name contains “T-shirt”:
REGEXP_CONTAINS(Product_Name, "T-shirt")
🔹 Check if a campaign name contains “sale” (case-insensitive):
REGEXP_CONTAINS(LOWER(Campaign_Name), "sale")
Tip: Using LOWER()
makes your match case-insensitive, perfect for marketing fields.
Real-World Use Cases
- Group branded vs. non-branded traffic:
REGEXP_CONTAINS(Campaign_Name, "nike|air max|jordan")
- Filter UTM Campaigns with discount keywords:
REGEXP_CONTAINS(UTM_Campaign, "discount|offer|sale|deal")
- Highlight messy source/medium values:
REGEXP_CONTAINS(Source_Medium, "email|newsletter|mailchimp")
- Catch multiple spellings or typos:
REGEXP_CONTAINS(Product_Category, "tshirt|tee shirt|t-shirt")
Pattern recognition inside messy data can seriously clean up your reports!
How to Use REGEXP_CONTAINS() in Looker Studio
- Click “Add a Field” in your data source.
- Name it (e.g.,
Branded Campaign
). - Enter this formula:
CASE
WHEN REGEXP_CONTAINS(Campaign_Name, "nike|air max|jordan") THEN "Branded"
ELSE "Non-Branded"
END
- Save and use your field in tables, charts, or filters!
✅ Congratulations! You’ve just grouped your campaigns automatically based on text patterns.
Pro Tips for Writing REGEX Patterns
- Use
|
for OR conditions: Match any one of multiple options. - Escape special characters: Parentheses
()
, periods.
, and plus signs+
often need escaping. - Use
.*
to match “anything in between”: Example:sale.*2025
matches “sale” followed by “2025” with anything in between.
Common Mistakes (And How to Fix Them)
❌ Case sensitivity: Without LOWER()
, “Sale” won’t match “sale”.
REGEXP_CONTAINS(LOWER(Campaign_Name), "sale")
❌ Matching numbers incorrectly: Regex treats numbers like any character. Match a specific number with quotes, e.g., "2025"
. To match any number, use [0-9]+
.
❌ Greedy patterns: If your regex is too broad, you’ll accidentally match extra text. Start simple and test gradually.
Troubleshooting REGEXP_CONTAINS()
- Check case sensitivity (use
LOWER()
if needed). - Ensure your field is text/string type.
- Test your regex on regex101.com before pasting into Looker Studio.
- Simplify your pattern first and build it step-by-step.
Conclusion
REGEXP_CONTAINS() is a simple but powerful way to filter and clean up messy text data in Looker Studio. With a few smart patterns, you can automate tagging, grouping, and cleaning without manual work.
Master a few regex tricks, and you’ll seriously upgrade your reporting skills!
Bonus: Copy-Paste REGEX Patterns
- Ecommerce discounts:
REGEXP_CONTAINS(UTM_Campaign, "sale|discount|offer|deal")
- Paid search sources:
REGEXP_CONTAINS(Source, "google|bing|yahoo|duckduckgo")
- Brand mentions:
REGEXP_CONTAINS(Page_Title, "nike|adidas|puma")