Regular expressions (regex) let you find patterns in text strings. Regex has its own syntax that uses special characters to represent the patterns you want to match, and many online resources explain how regular expressions work if you want to learn the basics. In integrator.io, you can use regex to find, replace, prefix, or append text patterns you define.
For information on using regex with Cash Application Manager (CAM), see Regular expressions with capture groups to extract specific information from a bank file and Regular expressions support for BofA, SVB, Wells Fargo, HSBC, and PNC wires.
Use regex in integrator.io
The most common integrator.io regex use cases wrap the regular expression in a Handlebars expression so the platform parses the pattern with a regex engine. Before you build a regular expression, test it with a regex tester such as regex101 to confirm it matches the patterns you want to capture. Then use it with one of these Handlebars helpers in a flow:
- regexMatch: Matches input data against the regular expression and returns the data based on the index and options.
- regexReplace: Returns a modified string with the matched pattern replaced.
- regexSearch: Searches for a match and returns the position of the result, where 0 is the first position.
Regex helper parameters
regexMatch, regexReplace, and regexSearch use the following parameters. The exact argument order varies by helper, so see each helper's article for its full syntax.
field -- The field or variable to match, replace, or search. Reference it by name, without quotation marks, curly braces, or parentheses.
regex -- The regular expression pattern to apply.
index -- The position of the result in the dataset, where 0 is the first position. regexSearch doesn't use this parameter.
options -- Flags that modify how the pattern is applied. By default, a regular expression stops at the first match; the g (global) flag tests against all matches in the string. See Advanced searching with flags.
Examples
Remove formatting from a phone number
Use regexReplace nested inside regexMatch to strip formatting from a 10-digit phone number. Given this field:
{
"phone": "(999) 888-7777"
}
this expression removes the parentheses, the space, and the hyphen, leaving the 10 digits:
{{regexMatch (regexReplace phone "" "[^\d]" "g") "\d{10}$" "g"}}
The result is 9998887777. The inner regexReplace replaces every non-digit character with an empty string, and the outer regexMatch confirms the result is 10 digits.
Extract a value between parentheses
Use regexMatch with a lookbehind and lookahead to return only the text inside parentheses. Given this field:
{
"exampleField": "(BR12345)-WIT-1"
}
this expression returns the value between the parentheses:
{{regexMatch exampleField "(?<=\()(.*?)(?=\))" "g"}}
The result is BR12345.
Supported regex functionality
integrator.io uses the Node.js built-in regular expression engine. For supported functionality, see these resources on Mozilla's developer site:
And these JavaScript string methods: