Guidelines for using regular expressions

When automating processes, you often come across situations where you need to use regular expressions to search for text patterns. You can use regular expressions to get text from documents or to search for windows by matching the window title to a text pattern.

Evaluate your regular expression in the IBM RPA Studio regular expression builder

You should validate if your regular expression is returning the results you expect by using the IBM RPA Studio's regular expression builder tool. Validate the results especially if you are using advanced or complex regular expressions or if you used a third-party tool to create the regular expression.

Consider storing regular expresions as an organized collection of data

You should consider storing regular expressions as an organized collection of data when working with multiple regular expressions, particularly when you have more than one regular expression to search for a single information. This organized collection of data can be a file with structured text, like a spreadsheet or a JSON file, or a database table.

When you store your regular expressions outside your script instead of hardcoding it to the script, you can change them without changing your script. You can also add more regular expressions to the collection without changing your script.

The following table is an example of storing regular expressions as a organized collection of data. This table could in be a CSV file, a spreadsheet, or a database table.

Data_to_extract Regex
Purchase_date \d{2}/\d{2]/\d{2,4}
Buyer_name \b.*\b
Purchase_date \d{2}\s*-.\s-\d*\b
Purchase_item \t.*\bSold