Use the Find
action to locate the position of a specified substring within a larger string.
It returns the index of the first occurrence of the substring allowing you to determine where
the substring appears within the main string.
This action also enables you to perform a search based on a regular
expression. 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: To search
for strings that contain the dollar sign ($), you must enter the sign twice.
Otherwise, the bot interprets the dollar sign as a regular expression
character.
Procedure
To find a substring from the specified string, follow these
steps:
-
In the
Actions
palette, double-click or drag the
Find
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
point.
For example, you want to replace
Red in the source string
with
Blue in a paragraph.
Red is in 10
instances in the paragraph and you want to replace only the third occurrence. Enter
3 in the
Start from field to
identify the third occurrence.
Note: If the specified substring
is not found, then the output will return as
0.
-
In the Assign the output to variable list, specify the
number variable.
-
Click Save.