Description
Searches an input string for occurrences of a regular expression and returns all successful matches.
Attributes
Input
Input - The string to be searched for matches.
Pattern - The regular expression pattern to match.
Regex Option - A bitwise combination of the enumeration values that specify options for matching.
Common
ContinueOnError - The Boolean value to specify whether to continue executing the next activities even if there is an error thrown on this activity.
Misc
DisplayName - Renames the activity.
Result - The collection of found matches.
Example
- Create a String variable and name it searchFor. For the Default value, write "RPA".
- Create an Array of String (String[]) variable and name it result.
- Add a Matches activity inside the initial Sequence.
- In the Matches Result field, add the result variable.
- In the Matches Input field, write the string shown in the screenshot below.
- In the Matches Pattern field, add the searchFor variable.
- Under the Matches activity, add an If activity.
- In the If Condition field, write result(0).ToString.Equals(searchFor). This would check if the first instance of result is equals with the value of searchFor.
- Inside Then, add a Message Box activity.
- In the Content field, write "A Match is Found!".
- Inside Else, add a Message Box activity.
- In the Content field, write "A Match is Not Found.".
The use case should look as the following screenshot:
A Message Box should be prompted upon execution. Since in this example, the value of searchFor is "RPA", the Message Box inside Then should be executed: