Regex - Multiple Results
Audience:
Low-code EngineersSkill Prerequisites:
Actions,Tokens,Regular expressions
Finds every match of a regular expression in a text and stores all the results in a token, as CSV, JSON or XML text. You can fill one, two or all three formats at once.
For example, from a text with several email addresses you can get ["ann@example.com","bob@example.com"] in a JSON token.
This action needs the Scripting feature in your license. If it isn't licensed, the action fails with a "not licensed" error.
Typical Use Cases
- Collect all email addresses, links, hashtags or IDs from a text
- Turn the matches into a list with Create List from JSON, then loop over them
- Build a comma-separated value, for example for a SQL
INclause or a tags field
Don't use it to
- Get only the first match, or several different values at once. Use Regex instead.
- Change or clean a text. Use Regex Replace instead.
- Read JSON. Use Parse JSON Into Tokens instead.
Related Actions
| Action Name | Description |
|---|---|
| Regex | Gets the first match of one or more patterns, each in its own token. |
| Regex Replace | Replaces the matches of a pattern in a text. |
| Create List from JSON | Turns the JSON result into a list. |
| Execute Actions for each List Entry | Runs actions once for each entry of that list. |
| Parse JSON Into Tokens | Reads the values of a JSON object into tokens. |
Comparing the regex actions
| Action | Patterns | Result |
|---|---|---|
| Regex | One or more rules, each with its own pattern, on one Input | The first match of each pattern, each in its own token |
| Regex - Multiple Results | One pattern | Every match, joined into CSV, JSON or XML text |
| Regex Replace | One or more rows, each with its own Input and pattern | The Input with every match replaced |
Input Parameter Reference
| Parameter | Description | Supports Tokens | Default | Required |
|---|---|---|---|---|
| Input | The text to search, usually a token such as [PostText]. | Yes | empty string | Yes |
| Regex Pattern | The pattern to find, for example #(\w+). If it has groups, each result is the first group instead of the whole match. If it's empty, the action does nothing. See How results are built. | No | empty string | Yes |
| Store CSV in token | The token that gets the results as separated text, for example TagsCsv. Leave it empty to skip this format. | No | empty string | No |
| CSV Field Separator | The separator for the CSV result: , i.e. comma, ; i.e. semicolon or tab. Use semicolon if you open the result in Excel with a regional format other than English (United States). If it isn't selected, comma is used. | No | comma | No |
| Store JSON in token | The token that gets the results as a JSON array of strings, for example TagsJson. Leave it empty to skip this format. | No | empty string | No |
| Store xml in token | The token that gets the results as XML, for example TagsXml. The name is also used for the XML elements. Leave it empty to skip this format. | No | empty string | No |
| Compile Regex | Compiles the pattern for faster matching. Compiled patterns run about 30% faster but use more memory, and the first run is about 3 times slower. Use it when the action runs often with the same pattern. | No | false | No |
In the three Store ... in token parameters, brackets and spaces around the name are removed, so [TagsJson] also works.
Output Parameters Reference
| Output | Description |
|---|---|
[<Store CSV in token>] | The results joined with the separator, for example ann@example.com,bob@example.com. Empty if nothing matches. |
[<Store JSON in token>] | The results as a JSON array of strings, for example ["ann@example.com","bob@example.com"]. [] if nothing matches. |
[<Store xml in token>] | The results as XML. See the format below. An empty root element if nothing matches. |
The results are text, not a list. To loop over them, load the JSON token with Create List from JSON. See Example 2.
How results are built
The action finds every match of the pattern in the Input, from left to right. For each match:
- No groups in the pattern. The result is the whole match.
- Groups in the pattern. The result is the first group only. Other groups are ignored. Unnamed groups
( )are numbered before named groups(?<name> ), and non-capturing groups(?: )don't count.
Results are kept in order, and duplicates are kept.
The XML format uses the token name for the elements. With Store xml in token set to TagsXml:
<TagsXmlRoot>
<TagsXml>summer</TagsXml>
<TagsXml>travel</TagsXml>
</TagsXmlRoot>
With no match, the value is <TagsXmlRoot />.
Pattern syntax and options
- .NET regular expressions. The pattern uses the .NET syntax, such as
\d,\w,\s,(?<name> ), lookaheads and inline options. - Case is ignored. The action always matches without case sensitivity. To match case, start the pattern with
(?-i). - Other options. There are no settings for multiline or singleline mode. Use
(?m)at the start of the pattern so^and$match at each line, or(?s)so.matches line breaks too. - Tokens aren't replaced in the pattern. Only Input supports tokens. So bracket sets such as
[a-z]are safe, but you can't build the pattern from a token value.
Considerations
- The CSV isn't escaped. Results are joined as they are, without quotes. If a result can contain the separator, a quote or a line break, the CSV breaks. Use the JSON format in that case.
- Use a valid XML name. The XML token name is used as an element name. A name with spaces, or one that starts with a digit, makes the action fail.
- Empty pattern or no token names. If Regex Pattern is empty, no token is set, and tokens from earlier runs keep their old values. If all three token names are empty, the action has no output.
- Invalid patterns fail the action. A syntax error in the pattern, such as an unclosed
(, raises an error when the action runs. - No timeout. The action doesn't set a match timeout. Patterns with nested repetition, such as
(a+)+$, can take a very long time on long inputs. Keep patterns simple and specific.
Examples
To understand how to use the below examples, please see Running Examples.
1. Collect all email addresses from a text
The MessageText token holds a text with several email addresses. This action stores them in [EmailsCsv], separated by semicolons, for example ann@example.com;bob@example.com.
{
"Title": "Regex - Multiple Results",
"ActionType": "RegexMultipleResults",
"Description": "Collect the email addresses in the message",
"Parameters": {
"Input": "[MessageText]",
"RegexPatternMultiple": "[\\w.+-]+@[\\w-]+\\.[\\w.-]+",
"CSVTokenName": "EmailsCsv",
"FieldSeparator": "semicolon",
"JSONTokenName": "",
"XMLTokenName": "",
"CompileRegex": false
}
}
2. Loop over the hashtags in a post
The PostText token holds a text such as Back from #Lisbon! #travel #summer. The pattern has a group, so each result is the tag without #. This action stores ["Lisbon","travel","summer"] in [HashtagsJson].
{
"Title": "Regex - Multiple Results",
"ActionType": "RegexMultipleResults",
"Description": "Find the hashtags in the post",
"Parameters": {
"Input": "[PostText]",
"RegexPatternMultiple": "#(\\w+)",
"CSVTokenName": "",
"JSONTokenName": "HashtagsJson",
"XMLTokenName": "",
"CompileRegex": false
}
}
Then this action loads the array into the HashtagsList list. If there are no hashtags, the list is empty and [HashtagsList:Count] is 0.
{
"Title": "Create List from JSON",
"ActionType": "LoadEntitiesFromJson",
"Description": "Load the hashtags into a list",
"Parameters": {
"JsonModel": "[HashtagsJson]",
"EntityName": "HashtagsList",
"EnforceISODateTime": false,
"OnError": []
}
}
Next, add Execute Actions for each List Entry with List Name set to HashtagsList. Each entry holds a simple value, so read it with [HashtagsList] inside the loop.
Revised 09/27/2026