Regex Merge Method
Usage | Parameters | Examples | Remarks
The Regex merge method uses regular expressions to search for and extract text snippets from larger text values.
Usage
Regex([SearchText],[Exp]) |
Extract text using a regular expression (regex) |
Regex([SearchText],[Exp],[Count]) |
Returns the total number of results captured with the regular expression |
Regex([SearchText],[Exp],[n]) |
Extract the n result of the regular expression where more than 1 result is expected |
Parameters
SearchText Text
The text containing the value to be captured
Exp Regular Expression
A Regular Expression to search for and retrieve the value to be captured.
Count Text (Optional)
Returns the count of the total number of results captured with the regular expression.
n Integer (Optional)
Identifies the result number to return from the collection of regular expression results. If no result number is provided then the first result is returned. If the result number does not exist then an empty value is returned.
Examples
Example 1
In the example below we retrieve a US social security number from a body of text. We are expecting the number to be separated with hyphens (-).
In this example, the result would be a value like "111-22-3333"
Example 2
In the example below we want to capture the text following the word "Invoice: " in the index "InvoiceHeader".
Name the file the text found after the word "Invoice: " until a new line occurs
Example 3
In the example below we want to use the portion of the index InvoiceNumber's value that ends in 3 upper case characters (but not include the the trailing characters)
An example of using a zone's value, but ignoring the last 3 characters
Example 4
In the example below we return a count of the number of results that meet the regular expression
In this example the file would be named "File Number 6"
Example 5
In the example below we read the second result of the regular expression
In this example the file would be named "User Name Smith"
Remarks
When using regular expressions in merge fields, Umango provides a handy regular expression builder tool. This is available by pressing the green regex button that will appear once you add a regex method to the merge field.
The regex builder button appears to the right of a merge field
The regex builder is way of building complex expressions with very little knowledge of regular expressions.
The regex builder
There are many online regular expression builders and helpers available online. A few include: