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:
- Extract Text
- Use the before, before and/or after, or the after settings to extract a sub-string from a body of text.
- Before: You provide the text that precedes the text you're interested in extracting, and the action will return everything that comes after.
- 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.
- 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.
- 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
- After: You provide the text that comes after the text you're interested in extracting, and the action will return everything that comes before.
- Use the before, before and/or after, or the after settings to extract a sub-string from a body of text.
- Find
- Use the find action to return the position of matching text within a larger body of text.
- Can be hard-coded text, or could be a regular expression.
- Substring
- Use the substring action to extract part of a larger body of text based on a start position and optional length.
- 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.
- Use the substring action to extract part of a larger body of text based on a start position and optional length.
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 our Community for more Quick Tips!