Regex NET code doesn't work on UIPath

Hello,

What is the best website to test for Regular Expressions? I know that UiPath usese NET Regex? I’m using http://regexstorm.net

Code works perfect in Regex Storm but doesn’t work on UiPath.
Pattern I use:
(?m)\d{1,2}\s(.*)\s[Bb][Uu][Cc]\s(\d+[.,]\d{1,3})\s(\d+[.,]\d{1,2})\s(\d+[.,]\d{1,2})\s(\d+[.,]\d{1,2})(?:\r?\n.*\p{L}\r?$)?

Input info:
Nr. Denumirea produselor U.M. Cantitatea (fara T.V.A.) Valoarea T.V.A.
crt. sau a serviciilor - lei - - lei - - lei -
0 1 2 3 4 5 (3x4) 6
1 asda-asda BUC 1.000 15.83 15.83 3.01
non-OEM-HP-CB435/CB436/CE278/CE285-B-2k
2 asda-asda BUC 2.000 22.20 44.40 8.44
non-OEM-HP-CF283X/CRG737-B-2.5k
3 asda-asda non-OEM-UTAX-PK-5015-B-4k BUC 1.000 138.43 138.43 26.30
4 asda-asda non-OEM-UTAX-PK-5015-B-4k BUC 1.000 137.76 137.76 26.17
5 asda-asda non-OEM-UTAX-PK-5015-C-3k BUC 1.000 126.27 126.27 23.99
6 asda-asda non-OEM-UTAX-PK-5015-M-3k BUC 1.000 126.27 126.27 23.99
7 asda-asda non-OEM-UTAX-PK-5015-Y-3k BUC 1.000 126.27 126.27 23.99
8 asda-asda BUC 2.000 22.20 44.40 8.44
2.5k
8 asda-asda BUC 2.000 22.20 44.40 8.44
Green vis-na
9 NT-SAMSUNG-MLT-D111L-UPDATE-FREE-B- BUC 2.000 22.20 44.40 8.44
1.8k
Another text is here that says something

Can you guys help me with this?
Thanks

  1. in uipath instead of (?m) you should use System.Text.RegularExpressions.RegexOptions.Multiline

what you can do is assign the following to a MatchCollection variable (where inputText = your input variable)

System.Text.RegularExpressions.Regex.Matches(inputText,"\d{1,2}\s(.*)\s[Bb][Uu][Cc]\s(\d+[.,]\d{1,3})\s(\d+[.,]\d{1,2})\s(\d+[.,]\d{1,2})\s(\d+[.,]\d{1,2})(?:\r?\n.*\p{L}\r?$)?",System.Text.RegularExpressions.RegexOptions.Multiline)

then you can now use your MatchCollection variable . For example, if i print these 2 lines

"Match 1, group 2 value = "+regexMatchCollection(0).Groups(2).Value
"Match 2, group 2 value = "+regexMatchCollection(1).Groups(2).Value

The result will be image
which is the expected result

Hi @jack.chan

I already did all of the above, but had a problem with the last group. I just realised now that I was using a noncapturing group… Transformed last group into a capturing one and everything is fine!

Thanks for your advice with the Multiline Option. Didn’t know about it. Also, code works fine with (?m), too!

I noticed that you use regex101.com. I used it too but had problems with some pattern instructions that don’t have the same syntax in NET Regex. In my opinion regexstorm.net is the real deal as it uses NET, not PCRE, same as UiPath, .

Would be great if any other people shared what website do they use to Regex. Maybe there is something way better.

Thanks a lot!
Robert

thanks, its just that im too used to using regex101 , i should start using regexstorm

1 Like

Hello

RegexStorm is the most compatible site with UiPath (100% as far as I know).

People use Regex101 because it’s easy to share patterns and for most scenarios is fine to use.

Hopefully this helps :blush:

1 Like

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