Using Replace action

Use the Replace action to find a piece of text from the source string and replace it with another text.

A regular expression is a sequence of characters that define a search pattern. For example, to find all email addresses in the source string, specify the following as a regular expression: \b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b.
Note:
  • The Replace action might not replace the Carriage Return and Line Feed (CRLF) characters in a string when you use the Enter variable. To ensure that the characters are replaced, instead of the Enter variable, use the Newline variable.
  • When you use the $ character in your regular expression pattern, the regular expression field might show an error as $ is considered as the start of a variable specification. Hence, we recommend you use $ instead.

Procedure

To replace text from the specified string, follow these steps:

  1. In the Actions palette, double-click or drag the Replace action from the String package.
  2. In the Source string field, specify the source string.
  3. In the Find string field, specify the substring.
  4. In the When finding field, select one of the options:
    • Match case: Matches the case of the text.
    • Do not match case: Does not match the case of the text.
  5. In the The "find string" is field, select one of the options:
    • A regular expression: The substring is a regular expression
    • Not a regular expression: The substring is not a regular expression.
  6. Optional: In the Start from field, specify the starting position.
    The action then starts from the value you specify in this field. For example, if you specify 5 in the Start from field for the source string "Big blue ocean", when the bot runs, the action ignores the four preceding characters ("Big", including the space character) and searches for the substring in "blue ocean".
  7. Optional: In the Count field, specify the number of times the found string must be replaced.
    For example, in the source string "Big blue ocean, blue fish, blue sky", you want to replace the first two instances of "blue" with "green". Enter 2 in the Count field, 5 in the Start from field, and green in the Replace with field. When the bot runs, the action produces the output green ocean, green fish, blue sky.
    Note: By default, the value in the Count field is set to -1, which means that all the instances of the found string will be replaced.
  8. In the Replace with field, specify the text to replace the string.
  9. In the Assign the output to variable list, specify the variable that will hold the new string.
  10. Click Save.