How to pull out Regex groups in UiPath Seperately


Im new to UiPath but have used regex previously within python. I know how to write an expression and pull out each single group using python e.g $1 $2 etc. but in UiPath im not sure how you would pull out each group seperately. I have used the Matches activity to input my regex and the string i am inputting and have tried to seperate the output by using a foreach and circle through each item however it dosent seperate the groups. it just keeps outputting as one line


That is currently what i am using. It might just be me expecting it to be seperating the output with the first message box showing

And the second message box showing

If anyone could help me with working out how to seperate the groups to seperate outputs that would be a massive help



Try using Split method: String.Split Method (System) | Microsoft Learn

Here we go.
splitTest.xaml (9.7 KB)

Thank you for that :slight_smile:

Is there anyway of doing this with regex though? cause i was hoping to be able to use a match to find a email for example and then split the email into sperate parts and output

e.g output everything before @ and everything after Seperately.

I have tried to use your method but because of the fact regex is stored in an IEnumerale it cant use split and cant be converted to a string in order to use split

It’s only matter of replacing string with regex .
For mail part i think you can check this post

Using your regex expression ([A-z]).([A-z])"
splitTest.xaml (9.8 KB)

1 Like

Awesome thank you so much for your help :slight_smile:

Im just so use to how regex is used in python my head couldnt grasp how to solve it.

Thank you


I had the same question as the one in the original post and didn’t want to settle on the Split solution :slight_smile:

Here’s my solution:

The Matches activity will return an IEnumerable<Match> and Match has a Groups method which returns a GroupCollection.

So if my activity output variable was matchOut and I wanted to get the first group in the first match instance, I would need:


Note that I used Groups(1).value because Groups(0).value would return the whole matched string, so matchOut(0).Groups(0).Value would be equivalent to matchOut(0).Value


Hello Thanks for your help.
Could you please tell me why we add .StringSpplitOptions.None ??

I had a similar question and struggled with the syntax for using regex groups in UiPath. Attached is another answer for Leon.Walker that uses Regex.Replace and callbacks: $1 $2 etc to solve the problem using the same Pattern from his question “([A-z]*).([A-z]*)”

Assigned 3 String Variables:
str = “Testing.test”
str1 = Regex.Replace(str,“([A-z]*).([A-z]*)”,“$1”)
str2 = Regex.Replace(str,“([A-z]*).([A-z]*)”,“$2”)

log message > str1 & Environment.NewLine & str2

(rework of ddpadil’s attachment:)
splitTest.xaml (10.5 KB)

1 Like

Hey @bogdan.gaspar

Can you attach your workflow for people to see and learn from? :slight_smile:

Interested in doing this myself.



Sure @Steven_McKeering ! Here is the sample.

I’m searching for word pairs in a given text with each word being in a group.
Then I’m iterating through the matches and for each match I’m iterating through the groups and printing the Value.

The output shows the indices for the match and the group and it’s easy to see the difference between Group(0) and Group(>0).

Hope this helps :slight_smile:

RegexMatches.xaml (10.4 KB)


Thank you, this helped me :slight_smile:

Exactly what I was looking for. This should be at the top of the page.

1 Like


It sounds like you have the answer already but feel free to check out this post from me which might be helpful :slight_smile:

Have a good day :smiley:

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.