Using RegEx matching in Segmentation
What is regex matching?
Regex matching lets you filter profiles based on text patterns instead of exact values. This is useful for finding profiles that follow a specific format, like email addresses from certain domains or phone numbers in a particular format.
⚠️ Important: Regex always matches the complete value from beginning to end.
How to use regex
When building a segment, you can use 2 regex operators with Text properties:
- matches regex - Includes profiles where the value matches your regex
- does not match regex - Includes profiles where the value does not match your regex
Use regex in the following segment conditions:
- Properties about someone (including custom objects). To use object data, first create a custom object. Learn how to use custom objects in segments.


- Filters on What someone has done (or not done) and Steps someone has taken (or not taken) in a specific order
Event funnels are included in Personalization and Advanced KDP. Learn how to use event funnels in segmentation.

Apply a regex filter
- Open the segment builder for a new segment, or open an existing segment and click Edit definition.
- Choose one of the conditions above and select the property to match. For an event condition, select an event and click its filter icon to choose the event property.
- Use a Text property. If the data type is editable, select Text.
- Select matches regex or does not match regex and enter your pattern.
- Click Create segment for a new segment or Update segment to save changes to an existing segment.
Regex basics
Matching characters
- Letters and numbers - Type normally: hello matches "hello"
- Any digit - Use \d to match any number 0-9
- Any letter - Use [a-z] for lowercase, [A-Z] for uppercase, or [a-zA-Z] for both
- Either/or - Use | to match options: gmail|yahoo matches either "gmail" or "yahoo"
- Anything - Use .* to match any characters
Special characters
Add a backslash \ before these to match them literally:
- Period: \. matches a period
- Plus sign: \+ matches a plus sign
- Parentheses: \( and \) match parentheses
Repeating patterns
- {5} - Exactly 5 times (e.g., \d{5} matches 5 digits)
- {2,4} - Between 2 and 4 times
- ? - Optional (0 or 1 time)
Note: Repetition bounds in {n}, {n,m}, or {n,} cannot exceed 1,000. This does not limit * or + to 1,000 repetitions.
Common examples
Email addresses
- Specific domain:
- .*@example\.com
- Matches: john@example.com, support@example.com
- Multiple domains:
- .*@(gmail|yahoo|hotmail)\.com
- Matches: user@gmail.com, user@yahoo.com, user@hotmail.com
- Any .com email:
- .*@.*\.com
Phone numbers
- 10-digit US number
- \d{10}
- Matches: 5551234567
- Formatted with parentheses:
- \(\d{3}\) \d{3}-\d{4}
- Matches: (555) 123-4567
Postal codes
- 5-digit ZIP:
- \d{5}
- Matches: 12345
- ZIP+4:
- \d{5}-\d{4}
- Matches: 12345-6789
For advanced references: our implementation uses Google RE2 as our standard. Learn more here.
Regex limits
Limit | Value | Example |
Regex length | max 1,000 characters | - |
Regex lines | max 100 lines | - |
Counted repetition bounds | Maximum bound: 1,000 | \d{1000} allowed |
Top-level | separators | Maximum 5 separators (6 alternatives) | a|b|c|d|e|f is allowed; a|b|c|d|e|f|g exceeds the limit |
Additionally, the following features are not supported at this time.
Feature | Example |
Lookahead/Lookbehind | (?=...), (?!...), (?<=...), (?<!...) |
Backreferences | \1, \2, (\w+)\s+\1 |
Unicode escapes | \uXXXX, \u00A0 |
Nested quantifiers | (a+)+, (x*)*, (a{2,5})+ |
Tips for success
1. Regex matches the complete value
Your regex must describe the entire value, not just part of it.
Wrong: gmail\.com (only matches the text "gmail.com")
Right: .*@gmail\.com (matches complete emails like john@gmail.com)
2. Escape literal periods
When matching .com, .net, etc., write it as \.com with a backslash.
Wrong: .*@gmail.com (the unescaped period matches any character)
Right: .*@gmail\.com (matches the literal period in emails like john@gmail.com)
3. Use .* for "Anything"
Match any characters with .*
- .*@company\.com - Any email at company.com
- \+.* - Anything starting with +
- .*urgent.* - Text containing "urgent"
4. Start simple, then refine
Begin with a basic regex and add details gradually.
- Example: .*@gmail\.com → [a-z]+\.[a-z]+@gmail\.com
Split complex logic into multiple simple conditions when possible. Join the conditions with AND when profiles must meet both, as in the example below.
- Example for "Gmail or Yahoo emails from California":
- Filter 1: Email matches regex .*@(gmail|yahoo)\.com
- Filter 2: State equals California
5. RegEx is case sensitive by default
If you want to make a statement case insensitive, you can add (?i) as a prefix.
- Product matches (?i)^iphone$
When to use regex vs. standard operators
Use regex when you need to match specific formats or patterns. For simpler needs, we strongly recommend using standard operators instead:
- Contains - Text appears anywhere
- Starts with - Matches the beginning
- Ends with - Matches the ending
- Equals - Exact match