"Is Match" activity not working as expected

Hi Team

Is Match activity does not work as expected. I just used simple pattern [a-z] when i given Max1234 in the input dialog then also boolean values becomes true. Could you please check and let me know if i am wrong.

Thanks,
UlaIsMatch.xaml (8.6 KB)

Hi @Boopathi,

What are you trying to achieve using ISMatch activity?

Your expression is [a-z] and your string is Max1234 and your expression matches with the string because your string has characters from a-z and A-Z and thats y it returns true

Hi @anil5 I want the result to be returned as true only if the pattern matches exactly but why the activity returns true value if the pattern matched is not correct. I want to use this activity for some validation purpose

Thank you but it also contains number so it is not matching with exact pattern. If we use this regex in https://regex101.com/ it will match with only alphabets.

Initially i used this regex “^([a-z_.]){5,10}$” for some validation but it does not work. Is match activity returns true even if the character length is more than 10 which is not correct.

Hi @Boopathi,

Use the below regular expression in assign statement, and the assign statement returns true or false

I have not used ISmatch activity, i have used Ismatch method

regex.IsMatch(“Max1234”,"(^|\s)[a-z]+(\s|$)",RegexOptions.IgnoreCase)

Hi @anil5 Thank you. I have used it and it is giving expected result but wondering why the same is not working using is match activity as it is useful to implement regex directly.

Hi @Boopathi,

Its working also in Is match activity, in Is match activity provide in value field this expression

(^|\s)[a-z]+(\s|$)
Refer the below workflow for reference
IsMatch.xaml (11.3 KB)

Hey @anil5,

May I know which activity are you using. It would be helpful for me to increase my understandings.

image

It is a IsMatch Activity.

And the properties are as shown in below screenshot

Hi @Boopathi,

Is the above working with Ismatch activity?

Hi @anil5

Thank you. It is working but really don’t understand how this activity works with your regex pattern as it is not working for the simple pattern [a-z] which is more than enough to accept only alphabets. Is there any bug in this activity or do i need to know any additional information? Also the properties appears in my uipath like the below one

image

Thanks,
Ula

My regex is similar to your pattern, its just you are using [a-z], i have used [a-z]+ and ^ and $ is for start and end of the string

(^)[a-z]+($)

hi @anil5 Yes, I understand your pattern and Initially I gave my pattern like this “/^([a-z])$/” but it did not work so i gave simply as [a-z]. I am giving in ismatch activity only after testing the pattern in the regex101 site. My only concern it is not working all the time. For example there is nothing wrong in this pattern ^([a-z_]){5,10}$ but if i use this pattern in the Ismatch activity it returns true if it is more than 10 characters also. Could you please try this pattern and check if it is working?

Thanks,
Ula

The expression works perfectly and for me and if the characters are more than 10 it returns false.

Refer the below workflow

IsMatch (2).xaml (9.3 KB)

3 Likes

Hi @anil5

Thank you but really it was not working previously and not sure where it was wrong as i checked it multiple times in regex101 before using in ismatch activity. I will check again with different patterns and come back to you. Thank you anil for looking into this. Do you know what it meas “Compiled” in the property?

Thanks,
Ula

Chceck with different patterns and let me know if it works.

Refer the below thread to know about different RegexOptions in Ismatch activity

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