Skip to main content
Version: 1.28 (Current)

Regex Replace

Audience: Low-code Engineers

Skill Prerequisites: Actions, Tokens, Regular expressions

Replaces text that matches a regular expression and stores the result in a token. Each row has its own input, pattern and replacement, so one action can clean or reformat several values.

For example, you can keep only the digits of a phone number, or turn 09/27/2026 into 2026-09-27.

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​

  • Remove unwanted characters, for example everything but digits from a phone number
  • Reformat values, such as dates or codes, by reordering the parts
  • Collapse repeated spaces or line breaks in user input
  • Mask part of a value, for example all but the last 4 digits of an account number

Don't use it to​

Action NameDescription
RegexGets the first match of one or more patterns, each in its own token.
Regex - Multiple ResultsGets every match of one pattern, as CSV, JSON or XML text.
Sanitize HTMLRemoves unsafe tags and attributes from HTML.
Create/Update TokensCreates or changes tokens with values you set.

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
DataThe replacements, one per row. Rows run in order. Each row has the columns below.See columnsemptyYes
  Store in TokenThe token that gets the result, for example PhoneDigits. Brackets around the name are removed, so [PhoneDigits] also works.Noempty stringYes
  InputThe text to change, usually a token such as [Phone]. It can use a token set by an earlier row of the same action.Yesempty stringYes
  PatternThe pattern to find, for example \D. Every match is replaced.Only if Apply tokens on pattern is checkedempty stringYes
  Replace withThe replacement text. It can refer to groups of the match, for example $1 or ${year}. Leave it empty to remove the matches. See Replacement syntax.Noempty stringNo
Apply tokens on patternWhen checked, tokens in Pattern are replaced before matching. See Tokens in the pattern.NofalseNo
Compile RegexCompiles the patterns 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 patterns.NofalseNo

Output Parameters Reference​

OutputDescription
[<Store in Token>]One token for each row of Data, with the Input after the replacements. If nothing matches, it's the Input unchanged.

Replacement syntax​

Replace with uses the .NET substitution syntax:

SyntaxInserts
$0The whole match
$1, $2, ...A numbered group
${name}A named group, for example ${year} for (?<year>\d{4})
$$A literal $

Write ${1} instead of $1 when a digit follows, for example ${1}0. Tokens aren't replaced in Replace with, so [Name] is inserted as it is.

Pattern syntax and options​

  • .NET regular expressions. Patterns use the .NET syntax, such as \d, \w, \s, (?<name> ), lookaheads and inline options.
  • Every match is replaced, not only the first one.
  • Case is ignored. The action always matches without case sensitivity, so cat also replaces Cat and CAT. 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 in the pattern​

By default, Pattern is used as it is. Bracket sets such as [a-z] or [0-9] are regex syntax, not tokens, and aren't touched.

When Apply tokens on pattern is checked, the pattern goes through token replacement first. Use it to build a pattern from a value, for example \b[BannedWord]\b. Keep in mind:

  • Brackets can be read as tokens. A bracket set whose content matches an existing token name is replaced by that token's value. A set that contains a :, such as [^:], can be removed. Avoid bracket sets in the pattern when this option is on, or test the pattern carefully.
  • Token values aren't escaped. Characters such as ., +, ( or ? in a token value act as regex syntax. For example, a value of a.b also matches axb.

Considerations​

  • Rows can build on each other. The Input of each row is read when the row runs, so a row can use the token of an earlier row. See Example 2.
  • Don't leave Pattern empty. An empty pattern matches between every character, so a non-empty Replace with is inserted everywhere.
  • Invalid patterns fail the action. A syntax error in a 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. Clean a phone number and reformat a date​

The first row removes everything but digits from [Phone], so (555) 123-4567 becomes 5551234567 in [PhoneDigits]. The second row turns a US date in [StartDate], such as 09/27/2026, into 2026-09-27 in [StartDateIso].

{
"Title": "Regex Replace",
"ActionType": "RegexReplacer",
"Description": "Normalize the phone number and start date",
"Parameters": {
"Data": [
{
"TokenName": "PhoneDigits",
"Input": "[Phone]",
"PatternValue": "\\D",
"ReplaceValue": ""
},
{
"TokenName": "StartDateIso",
"Input": "[StartDate]",
"PatternValue": "^(\\d{2})/(\\d{2})/(\\d{4})$",
"ReplaceValue": "$3-$1-$2"
}
],
"ApplyTokensOnPattern": false,
"CompileRegex": false
}
}

2. Clean up a comment​

The first row replaces any run of spaces, tabs or line breaks in [Comment] with one space. The second row reads the result of the first row, [CleanComment], and removes the spaces at the start and end.

{
"Title": "Regex Replace",
"ActionType": "RegexReplacer",
"Description": "Collapse whitespace and trim the comment",
"Parameters": {
"Data": [
{
"TokenName": "CleanComment",
"Input": "[Comment]",
"PatternValue": "\\s+",
"ReplaceValue": " "
},
{
"TokenName": "CleanComment",
"Input": "[CleanComment]",
"PatternValue": "^\\s+|\\s+$",
"ReplaceValue": ""
}
],
"ApplyTokensOnPattern": false,
"CompileRegex": false
}
}

3. Mask an account number​

This action replaces every digit that has at least 4 more digits after it with *. So 1234567890 becomes ******7890 in [MaskedAccount].

{
"Title": "Regex Replace",
"ActionType": "RegexReplacer",
"Description": "Show only the last 4 digits",
"Parameters": {
"Data": [
{
"TokenName": "MaskedAccount",
"Input": "[AccountNumber]",
"PatternValue": "\\d(?=\\d{4})",
"ReplaceValue": "*"
}
],
"ApplyTokensOnPattern": false,
"CompileRegex": false
}
}

Revised 09/27/2026