I have a scenario here where I wanted to extract a value inside a parentheses. Using the Matches activity in UIPath, I’m able to do just that. Here’s how:
Look for Matches activity and drop it on your workspace. I added a Message Box below to see the output.
![](https://3.bp.blogspot.com/-igoZIaawC0U/XCzSWKgNbnI/AAAAAAAAOg8/npVdd-m42J4DGiPMGd_1LODad_kyofmgACLcBGAs/s1600/matches.png)
On the Properties panel, fill in the Input (string) and Pattern (regex). For the Result, create a new variable with data type IEnumerable<Match>. This will hold all the matches found in your string input.
![](https://1.bp.blogspot.com/-y6fWqN4iIvc/XCzSY042ZrI/AAAAAAAAOhA/31GK-7fnX7ASRP0KVXK_Z2IEiqZAK5eqQCLcBGAs/s1600/matches.png)
Input: “I want to extract (value) here”
Pattern: “\((.*?)\)”
Result: RegexMatch (var with DataType IEnumerable<Match>)
Since I know I’m only looking for 1 match, I don’t need to loop through the result array. I can simply access the first value by checking index 0, hence RegexMatch(0).ToString in the Message Box.
This will output the following:
![](https://1.bp.blogspot.com/-2kr8MAPS1-Y/XCzUujLV0VI/AAAAAAAAOhQ/-3b92qMvm-sh1W_oj2Cac9bTi3kow0fEQCLcBGAs/s1600/matches.png)
Knowledge of regular expressions is needed here, thankfully there’s Google! If you want to validate your regex before running the activity, you can use this link: http://regexstorm.net/tester