About Regex Segmentation
The Segment Builder supports a Regex match type for text-based conditions. This is the right tool when a single Equals, Contains, Starts with, or Ends with can't express what you need — for example, matching multiple variations of a domain, validating a format, or capturing one of several values in a single condition.
In this article you'll find what regex is and where it's available in the Segment Builder, the supported syntax, worked examples for common use cases, and a troubleshooting table for the most common regex mistakes.
In this article
🚨 For advanced users only: Regex is unforgiving — a typo in the pattern can silently produce a Segment that matches nothing, or matches too much. Always Calculate and Show Profiles before using a regex Segment in a live send. If you're not familiar with regex syntax, use the standard Contains / Starts with / Ends with operators instead.
About regex in the Segment Builder
A regular expression — or regex — is a sequence of characters that defines a search pattern. Where Contains "gmail" matches only the literal string "gmail", a regex like gmail|hotmail|outlook can match any of three values in a single condition.
The Segment Builder supports a subset of regex features. The full list of supported syntax is in the Supported syntax section below.
Where you can use regex
Regex is available as a match type on:
Text Attributes — for example, First name, Email, City, or any custom text Attribute
Text-based Event data — for example, the address field within a Sign-up bar Submit event, or the URL string in a Page view event
To use regex on a condition, open the cogwheel and select Regex as the match type from the operator dropdown.
Supported syntax
When working with regular expressions in the Segment Builder, it is important that you consider the following limitations in order to successfully use the Regex Match Type. These are the specifications as to what the Segment Builder allows:
1 and 2 bit unicode characters.
[abc] , [^abc] - ranges.
[a-q] , [A-Q] , [0-7] , [^a-q] , [^A-Q] , [^0-7] - "between" ranges.
(a|b) - alternatives.
. - any character except new line.
* , + , {n,m} , {n,} , {n} - quantifiers.
^ , $ - beginning and end of the string.
Syntax | Meaning | Example |
| Standard ASCII and most extended characters | Letters, digits, common symbols |
| Match any single character in the set |
|
| Match any single character not in the set |
|
| Match a character in the range |
|
| Match a character outside the range |
|
| Match alternatives — either pattern works |
|
| Match any single character except a newline |
|
| Match the preceding character zero or more times |
|
| Match the preceding character one or more times |
|
| Match exactly n, at least n, or between n and m times |
|
| Anchor to the start of the string |
|
| Anchor to the end of the string |
|
⚠️ Note: Lookaheads, lookbehinds, named groups, backreferences, and other advanced regex features are not supported. If your pattern needs them, build the logic with multiple standard conditions joined by AND/OR instead.
Common use cases
Match multiple email domains in one condition
Goal: capture Profiles whose email is on Gmail, Hotmail, or Outlook.
Condition: Email attribute
Operator: Regex
Pattern:
@(gmail|hotmail|outlook)\.
Without regex this would be three separate conditions joined by OR. With regex it's one.
Match a postcode format
Goal: capture Profiles whose postcode follows the UK format (e.g. SW1A 1AA).
Condition: Postcode attribute
Operator: Regex
Pattern:
^[A-Z]{1,2}[0-9][A-Z0-9]? [0-9][A-Z]{2}$
Match URLs that include a year
Goal: capture page views on any blog post URL that ends with a 4-digit year (e.g. /blog/article-2026).
Condition: Page view event, URL string data
Operator: Regex
Pattern:
/blog/.*-[0-9]{4}$
Match Profiles whose first name starts with a specific letter range
Goal: A/B test segmentation — capture Profiles whose first name starts with A through M.
Condition: First name attribute
Operator: Regex
Pattern:
^[A-Ma-m]
💡 Tip: Test your regex on a regex sandbox like regex101.com before pasting it into the Segment Builder. Paste a few real values from your audience and confirm the pattern matches what you expect.
Troubleshooting
Issue | Likely cause | Fix |
Segment returns 0 Profiles but the data is clearly there | Case sensitivity — regex is case sensitive by default | Add both cases to your character set, e.g. |
Pattern matches far more Profiles than expected | Missing anchors — without | Anchor the pattern. |
Special character isn't matching as a literal | Characters like | Escape with a backslash, e.g. |
Lookahead, lookbehind, or backreference doesn't work | Not supported in the Segment Builder | Rewrite using only the supported syntax, or split into multiple AND/OR conditions |
Pattern works on regex101 but not in the Segment Builder | Different regex flavours — regex101 defaults to PCRE; the Segment Builder uses a more limited subset | Check your pattern against the Supported syntax table. Remove any feature not in the list |
Unicode character not matched | Only 1- and 2-byte Unicode is supported | For 3- or 4-byte characters (some emoji, rare scripts), fall back to standard Contains operators |
What's next?
Creating a Segment — The full guide to the Segment Builder, including standard text operators (Contains, Starts with, Ends with).
Segmentation Use Cases — Step-by-step examples of common Segments — many of which don't need regex.
Export Profiles — Export the Profiles captured by your regex Segment.
