Issue with RegEx in Matches


#1

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


#2

Hi @pavanigangireddy,

Can you give us a test text?

Regards,
Susana


#3

Hi Susana,

Please find the test text.

01234567894546
0120758765668767
5675460086433578


#4

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.


#5

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,


#6

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


#7

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.


#8

Hi,

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


#9

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


#10

Hi, @pavanigangireddy
I get output like this…

This is My flow
Regex_match.xaml (9.3 KB)

Regards,