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:

  1. In the Actions palette, double-click or drag the Extract text action from the String package.
  2. In the Source string field, specify the source string.
  3. Specify the text to extract by selecting from the following options:
    OptionSteps
    Before Extracts the entire text followed by the value that you have provided in the Start after text field.
    1. In the Start after text field, enter a string to use as the starting point.
    2. 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 after This. To extract the required text, you must enter This in the Start after text field and 1 in the Occurrence field. This indicates to the system to extract the text that is available after the first occurrence of This 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.
    1. In the Start after text field, enter a string to use as the starting point.
    2. 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.
    3. In the End before text field, specify a string to use as the endpoint for extracting the text.
    4. 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 before specific. To extract the required text, you must enter specific in the End before text field and 1 in the Occurrence field. This indicates to the system to extract the text available before the first occurrence of specific in the source string.

    After Extracts the entire text preceding the value you have provided in the End before text field.
    1. In the End before text field, specify a string to use as the endpoint for extracting the text.
    2. 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 before specific. To extract the required text, you must enter specific in the End before text field and 1 in the Occurrence field. This indicates to the system to extract the text available before the first occurrence of specific in the source string.

  4. 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.
  5. 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.
  6. 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.
  7. 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.
  8. In the Remove Enter from the extracted text check box, select to remove carriage returns from the extracted text.
  9. In the Assign the output to variable list, specify the variable.
  10. Click Save.