Articles in this section

regexSearch helper

The regexSearch helper returns the zero-based index of the first substring that matches a regular expression pattern within a string. If no match is found, it returns -1. Use it to locate the position of a pattern before extracting or replacing it.

Syntax

{{regexSearch field regex options}}

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

regex -- The regular expression pattern to locate. Required.

options -- Regex flags to apply. Optional. Common values: "i" (case-insensitive), "m" (multiline).

Examples

Find the position of a character

{{regexSearch record.total "5"}}

Input: record.total is "$1499.95"
Output: 7

The first "5" appears at index 7 (zero-based).

Find the position of the decimal point

{{regexSearch record.total "\."}}

Input: record.total is "$1499.95"
Output: 5

The "." appears at index 5. The backslash escapes the dot so it matches a literal period rather than any character.

{{regexSearch record.comment "celigo" "i"}}

Input: record.comment is "HELLO Celigo"
Output: 6

The "i" flag matches regardless of case. "Celigo" starts at index 6.

Usage notes

  • The return value is zero-based: the first character is at index 0.
  • Returns -1 when the pattern is not found. Handle this in downstream mappings to avoid unexpected behavior.
  • Triple braces are not needed -- the helper returns a plain number that is not subject to Celigo's automatic string formatting.
  • For more on regex syntax and supported patterns, see Regular expressions (regex).