Skip to main content
Version: 1.28 (Current)

Regex - Multiple Results

Audience: Low-code Engineers

Skill 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.

note

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 IN clause or a tags field

Don't use it to​

Action NameDescription
RegexGets the first match of one or more patterns, each in its own token.
Regex ReplaceReplaces the matches of a pattern in a text.
Create List from JSONTurns the JSON result into a list.
Execute Actions for each List EntryRuns actions once for each entry of that list.
Parse JSON Into TokensReads the values of a JSON object into tokens.

Comparing the regex actions​

ActionPatternsResult
RegexOne or more rules, each with its own pattern, on one InputThe first match of each pattern, each in its own token
Regex - Multiple ResultsOne patternEvery match, joined into CSV, JSON or XML text
Regex ReplaceOne or more rows, each with its own Input and patternThe Input with every match replaced

Input Parameter Reference​

ParameterDescriptionSupports TokensDefaultRequired
InputThe text to search, usually a token such as [PostText].Yesempty stringYes
Regex PatternThe 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.Noempty stringYes
Store CSV in tokenThe token that gets the results as separated text, for example TagsCsv. Leave it empty to skip this format.Noempty stringNo
CSV Field SeparatorThe 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.NocommaNo
Store JSON in tokenThe token that gets the results as a JSON array of strings, for example TagsJson. Leave it empty to skip this format.Noempty stringNo
Store xml in tokenThe 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.Noempty stringNo
Compile RegexCompiles 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.NofalseNo

In the three Store ... in token parameters, brackets and spaces around the name are removed, so [TagsJson] also works.

Output Parameters Reference​

OutputDescription
[<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​

tip

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