Looker Studio Function : REGEXP_CONTAINS
REGEXP_CONTAINS Function in Looker Studio – Advanced Text Matching Explained
Category: Text Function
The REGEXP_CONTAINS function in Looker Studio is a powerful text function used to check whether a text value matches a regular expression pattern. Unlike basic text functions such as CONTAINS_TEXT, this function allows complex and flexible matching logic using regex rules. It returns TRUE or FALSE depending on whether the pattern is found.
In real reporting scenarios, data is often messy and inconsistent. Campaign names, URLs, product descriptions, and tracking parameters usually follow patterns rather than fixed values. REGEXP_CONTAINS helps analysts identify these patterns accurately. For example, checking whether a URL contains certain parameters, identifying multiple keywords in a single condition, or validating text formats.
From a BI perspective, REGEXP_CONTAINS is commonly used in calculated dimensions, filters, and CASE statements. It helps avoid multiple nested conditions and keeps logic clean and scalable. Although it is more powerful than simple text functions, it should be used carefully to avoid unnecessary complexity.
Overall, REGEXP_CONTAINS is an essential function for advanced text analysis in Looker Studio.
Purpose of REGEXP_CONTAINS Function
1. Advanced Pattern Matching
Allows checking complex text patterns using regular expressions.
2. Multi-Keyword Identification
Helps identify multiple keywords or formats in a single condition.
3. Flexible Data Classification
Used to classify unstructured text data into meaningful groups.
4. Text Validation
Validates text formats like URLs, IDs, or naming conventions.
Type of Calculation & Practical Use Cases
1. Boolean Calculation
REGEXP_CONTAINS returns TRUE or FALSE based on regex match.
2. Calculated Dimensions
Commonly used inside calculated dimensions for tagging and grouping.
3. Conditional Logic
Works well with IF and CASE for advanced decision logic.
4. Data Cleaning & Filtering
Helps filter unwanted or irrelevant text patterns.
REGEXP_CONTAINS(text, regular_expression)
REGEXP_CONTAINS Function – Parameters Table
| Parameter | Type | Description |
|---|
| text | Text | The text value to be evaluated |
| regular_expression | Text | Regex pattern to search for |
How Does the REGEXP_CONTAINS Function Work?
The REGEXP_CONTAINS function evaluates the given text value against a regular expression pattern. If the pattern matches any part of the text, the function returns TRUE; otherwise, it returns FALSE.
The matching is case-sensitive by default, so patterns must be written carefully. The function processes data row by row, making it suitable for large datasets. Since regex patterns can be complex, improper usage may impact readability or performance, so testing is always recommended.
When Should You Use REGEXP_CONTAINS Function?
When simple text functions are not sufficient
When matching multiple keywords in one condition
When working with pattern-based text data
When validating structured text formats
When reducing complex nested conditions
Examples of REGEXP_CONTAINS Function
Example 1: Identify Multiple Campaign Types
REGEXP_CONTAINS(Campaign_Name, "sale|offer|discount")
Returns TRUE if any keyword exists.
Example 2: Filter URLs with Parameters
REGEXP_CONTAINS(Page_URL, "utm_source=")
Example 3: Use with CASE Statement
CASE
WHEN REGEXP_CONTAINS(Channel, "facebook|instagram") THEN "Meta Ads"
ELSE "Other Channels"
END
Tips & Best Practices
Use simple regex patterns whenever possible
Avoid over-complicated expressions
Test regex logic on sample data first
Prefer CONTAINS_TEXT for simple cases
Document regex logic for better maintainability
Yes, it is case-sensitive by default.
For complex patterns, yes. For simple cases, CONTAINS_TEXT is better.
Complex regex may impact performance on large datasets.
It is mainly used in calculated dimensions and logical expressions.
The function returns FALSE or NULL.