Using Extract text action of String package
- Updated: 2022/11/27
Using Extract text action of String package
Use the Extract text action to extract a range of text using logical operators from the source string.
Review examples of using Before, After, and Before and/or After options in Examples of using Extract text action.
Procedure
To extract a substring from the specified source string, do the following:
- In the Actions palette, double-click or drag the Extract text action from the String package.
- In the Source string field, specify the source string.
-
Specify the text to extract by selecting from the following options:
Option Steps Before Extracts the entire text followed by the value that you have provided in the Start after text field. - In the Start after text field, enter a string to use as the starting point.
- In the Occurrence field, enter a value to
specify the number of occurrences.
For example, if the source string is
This is a test string which is used to extract specific sub-string
and you want to extract the entire text afterThis
. To extract the required text, you must enterThis
in the Start after text field and1
in the Occurrence field. This indicates to the system to extract the text that is available after the first occurrence ofThis
in the source string.
Before and/or after Extracts the text between the values provided in the Start after text and the End before text fields. - In the Start after text field, enter a string to use as the starting point.
- In the OR or AND
field, select one of the options:
- OR: Select to extract text if either of the values specified in the Start after text or the End before text field are available in the source string.
- AND: Select to extract text if both the values specified in the Start after text and the End before text fields are available in the source string.
- In the End before text field, specify a string to use as the endpoint for extracting the text.
- In the Occurrence
field, enter a value to specify the number of occurrences of the
string you have provided in the End before
text field.
For example, if the source string is
This is a test string which is used to extract specific substring
and you want to extract the entire text beforespecific
. To extract the required text, you must enterspecific
in the End before text field and1
in the Occurrence field. This indicates to the system to extract the text available before the first occurrence ofspecific
in the source string.
After Extracts the entire text preceding the value you have provided in the End before text field. - In the End before text field, specify a string to use as the endpoint for extracting the text.
- In the Occurrence
field, enter a value to specify the number of occurrences of the
string you have provided in the End before
text field.
For example, if the source string is
This is a test string which is used to extract specific substring
and you want to extract the entire text beforespecific
. To extract the required text, you must enterspecific
in the End before text field and1
in the Occurrence field. This indicates to the system to extract the text available before the first occurrence ofspecific
in the source string.
-
In the If no match found, return field, select one of
the options:
- Source String: Return the source string.
- Empty (null) String: Return the null string if no match is found.
-
In the When extracting field, select one of the
following options:
- Match case: Matches the case of the text in the source string
- Do not match case: Does not match the case of the text in the source string
Note: By default, the Match case option is selected for all the new and existing bots. -
In the Number of characters to get field, select one of
the options:
- All: Extracts all characters from the source string.
- Only: Specify the exact number of characters to extract from the source string.
- Up to: Specify the
maximum number of characters that you want to extract from the source
string.Note: This option enables you to provide a maximum limit of the characters that you want to extract. However, it is not mandatory that the source string contain the number of characters that you enter in this field.For example, the source string has Date+8 as its value and you want to extract the characters after the string Date. You enter 10 in the Up to field, to extract 10 characters from the source string that appears after the string Date. When you run the bot, the output is +8 and it returns all the values after the string Date.Note: The value 10 only depicts the maximum number of characters that you want to extract.
-
In the Trim the extracted text (remove blank spaces) check
box, select to remove blank spaces from the extracted text.
For example, you extract an email from a website and then add it to an Excel sheet. To remove any unwanted spaces from this extracted email text, you can use the Trim the extracted text (remove blank spaces) option. Alternatively, you can use the Trim action to remove any space before and after this extracted email text.
- In the Remove Enter from the extracted text check box, select to remove carriage returns from the extracted text.
- In the Assign the output to variable list, specify the variable.
- Click Save.