Search And Replace Regex
  • 07 Dec 2020
  • 1 Minute to read
  • Dark
    Light
  This documentation version is deprecated, please click here for the latest version.

Search And Replace Regex

  • Dark
    Light

Article summary

Overview

This tutorial demonstrates how to use the Regex Replace Step in Decisions. The Regex Replace step is intended to lookup text input by a regular expression pattern and replaces text that matches the pattern.

Note
The following example utilizes a specific Regex Pattern to replace the text. For more information on how Regex Patterns work see the references at RegexR

Example

Begin in the Designer Folder by clicking Create Flow on the Folder Actions Panel.

In the resulting window,  Name the Flow and click CREATE to proceed to the Flow Designer.

In the Flow Designer, add the Regex Replace Step from the All Steps [Catalog] > Data > Text category.

Connect the Done outcome from the Replace Regex Step to the End Step in the Flow. Select the Regex Replace Step on the workspace to set it up. For the Input called input, use a Constant String that represents random numeric values with different currency signs (trailing and leading the value); for example: 

$17.43 €2 16.33 £0.98 0.43 £43 €1217

Under the options Input, set the mapping to Ignore.

Note
There are options like IgnoreCase, Multiline, ExplicitCapture, Compiled, Single-line, IgnorePatternWhiteSpace, RightToLeft, ECMAScript to Advance the Regex Search Pattern.


Define the Constant Pattern as follows:

(\p{Sc}\s?)?(\d+L?)((?<=\.)\d+)?(?(1)|s?\p{Sc})?


Define the Constant replacement Input that removes either a leading or a trailing currency symbol from a numeric value; this example utilizes $2.

This completes the Flow; Save and Close to save changes. 

Debugging 

Upon successful running in the Debugger; the Flow displays the Input String to the Regex Replace step.

(\p{Sc}\s?)?(\d+L?)((?<=\.)\d+)?(?(1)|s?\p{Sc})?

$17.43 €2 16.33 £0.98 0.43 £43 €1217

As an Output from the Regex Replace Step, the Flow displays the String that represents numerical values without any undesired currency characters.



Was this article helpful?