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

SyntaxNameDescriptionExample
.DotMatches any single characterh.llo matches “hello”, “hallo”
*StarZero or more of the previous elementab*c matches “ac”, “abc”, “abbc”
+PlusOne or more of the previous elementab+c matches “abc”, “abbc” but not “ac”
|AlternationMatches either sidecat|dog matches “cat” or “dog”
()GroupingGroups elements together(ab)+ matches “ab”, “abab”
\EscapeTreats next character as literala\.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 matchUse
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

  1. Patterns are unanchoredhello matches “say hello world”. You don’t need .*hello.*.
  2. Use alternation for multiple keywordserror|warning|critical matches any of the three words.
  3. Keep patterns simple — the supported syntax covers most common matching needs without the complexity of full regular expressions.