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
.
Procedure
To replace text from the specified string, follow these
steps:
-
In the Actions palette, double-click or drag the
Replace
action from the String
package.
-
In the Source string field, specify the source
string.
-
In the Find string field, specify the substring.
-
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.
-
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.
- 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".
- 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.
-
In the Replace with field, specify the text to replace
the string.
-
In the Assign the output to variable list, specify the
variable that will hold the new string.
-
Click Save.