BACK

Quick Tip: Advanced String Manipulation

In this session, we’ll look at the String Package and discuss approaches for extracting a sub-string. When extracting data from web applications, OCR’d text from images, or even an Excel file – data unfortunately doesn’t always come in the perfect format we need it in – which is why its important to understand how best to extract out the text you need.

Video Recap:

  1. Extract Text
    1. Use the before, before and/or after, or the after settings to extract a sub-string from a body of text.
      1. Before: You provide the text that precedes the text you’re interested in extracting, and the action will return everything that comes after.
      2. Before and After: You provide the text that precedes the text you’re interested in as well as the text which comes after the text you’re interested in. The action will return all the text that comes between the two.
      3. Before or After: You provide the text that may precede the text you’re interested in as well as the text which may come after the text you’re interested in. The action will attempt to return the preceding/subsequent text.
        1. Note: Be sure to do lots of testing when using Before or After so you know exactly what kind of text the bot should expect as a return
      4. After: You provide the text that comes after the text you’re interested in extracting, and the action will return everything that comes before.
  2. Find
    1. Use the find action to return the position of matching text within a larger body of text.
    2. Can be hard-coded text, or could be a regular expression.
  3. Substring
    1. Use the substring action to extract part of a larger body of text based on a start position and optional length.
      1. The optional length lets you specify how many characters you intend to extract, the alternative is that text from the starting position through the end of the provided source string would be extracted.

Bonus Tip

If you need to, you could combine some of these operations in different ways as well as include additional String actions like the Split action to break up a string into a list of substrings or Length to get the length of a source or returned string value.

Be sure to stay tuned to developer.automationanywhere.com for more Quick Tips!