Articles in this section

regexMatch helper

The regexMatch helper searches a string using a regular expression and returns the matching substring. Use it to extract specific patterns -- such as IDs, dates, or codes -- from field values. You can specify which match occurrence to return and apply standard regex flags.

Syntax

{{regexMatch field regex index options}}

field -- The field or string to search. Required.

regex -- The regular expression pattern to match against. Required.

index -- The zero-based occurrence to return. Optional. Defaults to 0 (the first match).

options -- Regex flags to apply. Optional. Common values: "g" (global), "i" (case-insensitive), "m" (multiline). Combine flags in a single string (e.g. "gi").

Examples

Extract the first match

{{regexMatch record.comment "[0-9]{5}"}}

Input: record.comment is "Order ID: 12345 delivered on 2025-04-20"
Output: 12345

With no index argument, the helper returns the first match (index 0).

Return a specific match occurrence

{{regexMatch record.comment "[0-9]{5}" 1}}

Input: record.comment is "IDs: 12345 and 67890"
Output: 67890

The index argument 1 returns the second match.

Apply regex flags

{{regexMatch record.comment "order id" 0 "i"}}

Input: record.comment is "ORDER ID: 98765"
Output: ORDER ID

The "i" flag makes the match case-insensitive.

Return raw output with triple braces

{{{regexMatch record.comment "[0-9]+"}}}

Use triple braces when downstream systems require the exact matched string without Celigo's automatic formatting.

Usage notes

  • index is zero-based: 0 returns the first match, 1 the second, and so on.
  • Add the "g" flag when you need to find multiple matches across the string. Without it, the helper stops after the first match.
  • Use triple braces ({{{ }}}) for raw output and double braces ({{ }}) when Celigo's default formatting is acceptable.
  • For more on regex syntax and supported patterns, see Regular expressions (regex).