Regular Expressions
Reference guide for the regular expression syntax supported in string conditions for validation, delivery customization, and payment customization functions.
Regular expressions (regexp) provide pattern matching for string conditions. Two operators are available in the condition builder:
- case-sensitive matching
- case-insensitive matching
Patterns are unanchored — they match if the pattern is found anywhere in the input string. You don’t need to wrap your pattern in .* to match a substring.
Availability
Regular expressions are available for string conditions in:
- Validation functions
- Delivery Customization functions
- Payment Customization functions
They are not available in Discount or Cart Transform functions.
Supported Syntax
| Syntax | Name | Description | Example |
|---|---|---|---|
. | Dot | Matches any single character | h.llo matches “hello”, “hallo” |
* | Star | Zero or more of the previous element | ab*c matches “ac”, “abc”, “abbc” |
+ | Plus | One or more of the previous element | ab+c matches “abc”, “abbc” but not “ac” |
| | Alternation | Matches either side | cat|dog matches “cat” or “dog” |
() | Grouping | Groups elements together | (ab)+ matches “ab”, “abab” |
\ | Escape | Treats next character as literal | a\.b matches “a.b” but not “axb” |
Combining Operators
Operators can be combined to build more complex patterns:
.*— matches any sequence of characters (zero or more).+— matches any sequence of characters (one or more)(cat|dog)+— matches one or more occurrences of “cat” or “dog”(a|b)*c— matches “c”, “ac”, “bc”, “aac”, “abc”, etc.
Examples
Address Matching
Detect P.O. Box addresses:
Pattern: p.*o.*(box)*
Operator: RegExp*
Matches: "PO Box 123", "P.O. Box 456", "Post Office Box 789"
SKU Patterns
Match a SKU format like “ABC-123”:
Pattern: ...-...
Operator: RegExp
Matches: "ABC-123", "XYZ-999"
Email Validation
Check if a value looks like an email:
Pattern: .+@.+
Operator: RegExp
Matches: "user@example.com"
Does not match: "no-at-sign"
Product Tags
Match products with specific tag patterns:
Pattern: premium|vip|exclusive
Operator: RegExp*
Matches: "Premium", "VIP", "exclusive", "PREMIUM-MEMBER"
Country Code Prefixes
Match phone numbers starting with specific country codes:
Pattern: \+1|011
Operator: RegExp
Matches: "+1-555-0100", "011-44-20"
Escaping Special Characters
If you need to match a character that has special meaning (. * + | ( ) \), prefix it with a backslash:
| To match | Use |
|---|---|
Literal . | \. |
Literal * | \* |
Literal + | \+ |
Literal | | | |
Literal ( | \( |
Literal ) | \) |
Literal \ | \\ |
What’s Not Supported
The regexp engine uses a minimal syntax optimized for performance. The following features are not available:
- Character classes:
[a-z],[^abc],[0-9] - Anchors:
^(start),$(end) - Optional quantifier:
? - Repetition counts:
{n},{n,m} - Shorthand classes:
\d,\w,\s - Backreferences
- Lookahead / lookbehind
- Named or capturing groups
Tips
- Patterns are unanchored —
hellomatches “say hello world”. You don’t need.*hello.*. - Use alternation for multiple keywords —
error|warning|criticalmatches any of the three words. - Keep patterns simple — the supported syntax covers most common matching needs without the complexity of full regular expressions.