Issue with RegEx in Matches

Hi,

I’m trying to use the below RegEx in Matches and it is not working.

“[24][0126]\d{10}”

When I tested this RegEx using RegEx testers, it is working properly. Please help.

Regards,
Pavani

Hi @pavanigangireddy,

Can you give us a test text?

Regards,
Susana

Hi Susana,

Please find the test text.

01234567894546
0120758765668767
5675460086433578

Hello,

The last two examples work fine; the first one doesn’t work because you have to have the following for a match: a 2 or a 4, followed by a 0, 1, 2 or a 6, followed by 10 digits. As you can see, 01234567894546 does not match because the 3 should be either a 0, 1, 2 or 6.

Hi, @pavanigangireddy
Try this…
Regex.Matches(var1,“(2|4)(0|1|2|6)\d{10}”)
This is working correctly for Me.
i hope this will helpful to You…
Regards,

Hi Florin, that’s right. But, my RegEx when used in UI Path is not finding those 2 matches.

Hi Hemanth,

I have used matches activity in UI Path and gave my regex for pattern. I have to give it as a string format. If I give a simple regex like “\d{10}”, it is working. But “[24][0126]\d{10}” is not working where as it’s working perfectly in all the regex testers.

Hi,

Have you tried it outside of the activity like in a Message Box?
You can do that using System.Text.RegularExpressions.Regex.Matches()

Hmm, that’s strange, those 2 examples work for me with Matches activity: Main.xaml (11.9 KB)

1 Like

Hi, @pavanigangireddy
I get output like this…

This is My flow
Regex_match.xaml (9.3 KB)

Regards,