The replace task is used to replace a string with another string. The replacement can be a specified character, or a regular expression (RegExp), from the original string. A RegExp is a sequence of characters that forms a search pattern. Read more about RegExp here.
Potential Use Case
Suppose you have a list of emails and you need to replace a specific email address with a new updated email address. Using the replace task will find the matching occurrence of the old email and replace it with the new one.
Input and output parameters are shown below.
||string||Required. The string that contains the value or regular expression to be replaced.|
||string||Required. A value or pattern within
||string||Required. The string that replaces the
||string||A new string where the
In this IAP example, the Reference variable for
str is "Hello World" and the
substr to look for and replace is the word "Hello". The Reference variable for the
newSubstr is the replacement word "Howdy".
The task will replace the word "Hello" with the word "Howdy" and the result that returns will be "Howdy World".
In this example the
substr contains a regular expression. The RegExp pattern to match will be /[eo]/g.
The letters "e" and "o" in the
str variable were replaced with the number "1" from the
newSubstr variable. The new
replacedString variable that returns is "H1ll1 W1rld".