Regular expressions (regex) allow you to find patterns in text strings. Regular expressions have a unique syntax that uses special characters to represent the patterns you want to find, and a variety of resources are available online if you want to familiarize yourself with how regular expressions work.
Note: For information on using regex with Cash Application Manager (CAM), see Use regex with capture groups to extract specific information from a bank file and Regular Expressions Support for BofA Wires, SVB, Wells Fargo, HSBC Wires and PNC Wires.
Contents
Regex for integrator.io
You can use regex to find, replace, prefix, or append instances of text patterns you define. The most common regex use cases for integrator.io wrap the regular expression in a handlebars format to allow the system to recognize that the pattern expressed should be parsed with a regex engine. When building a regular expression, you should first use a regex tester to verify your regular expression matches the patterns you want to capture. You can then use your regular expression with one of the following handlebars expressions to perform the operation within the context of a flow:
- regexMatch: Use this to match the input data based on the regular expression and return the data based on index and options variables.
- regexReplace: Use this to return a modified string where the pattern has been replaced.
- regexSearch: Use this to search for a match, and return the position of the result in the dataset, where 0=first position and 2=third position.
regexMatch, regexReplace, and regexSearch handlebars expressions require you to enter the following parameters:
- field: the field name containing the variable or values to be matched, replaced, or searched. You can reference a field or variable by typing its name without double quotes (or curly braces or parens).
- regex: the new value which will match, replace, or search the existing value.
- index: the position of the result in the dataset, where 0=first position and 2=third position.
- options: Regex options allow you to modify the search behavior of the expression. For example, regular expressions stop at the first match in the text content by default. A "g" entered in the options position sets the expression to global (meaning that the expression will attempt to match all matching instances throughout the entirety of the text content). For more information on regex options, see regex options.
Note: The index parameter is not used in regexSearch.
Use regexReplace to map null fields to empty strings
The following handlebar expression sets the mapping to an empty string if the exampleField field is null. You can use this in conjunction with the Discard if empty checkbox to discard this mapping if exampleField is null. Here, exampleField is a field reference.
{{#if exampleField}}{{{regexReplace examplefield "" "(Field name: )" w}}}{{else}}{{/if}}
- Do not use any double quotes, curly braces, or parens to reference a field or variable, just type the name.
- Use double quotes to reference a hard-coded string.
Use regexReplace to format phone numbers
The following handlebars expression uses regexReplace to apply formatting to phone number fields. If the field values are 10 digits with no formatting:
9998887777
This expression adds parens to the first three digits, adds a space, and inserts a hyphen after the next three digits.
(999) 888-7777
Use the following handlebars expression:
{{regexReplace this.0.[Phone] "" "[^0-9]" "g"}
Use the following expression if you want to insert a leading 1 to the reformatted value:
{{regexMatch (regexReplace this.0.[Phone] "" "[^\d]" "g") "\d{10}$" "g"}}
Comments
0 comments
Please sign in to leave a comment.