Regular expression not working

Any possible reason for validate not working in this case though element attribute ‘idx’ is just 3 digit number only.

Hi @neha.verma ,

You would also require to add another attribute :

matching:idx='regex'

Check the below post on how to use regex in Selectors :

Hello @neha.verma
You can provide ???
?- replaced 1 charector
hope this helps.
Sorry dont have idea regex works in selectors or not.

added matching:idx=‘???’ and still fails validation. Infact after adding matching tag, it fails with exact value as well indicating that matching keyword is not working here. Any suggestions?

@neha.verma ,

Could you provide us with the Selector that you are using ?

I tried and it fails.

without providing matching provide idx=???
Hope this helps

@neha.verma ,

In the Selector, you have to provide the regex expression in the idx attribute itself :

idx = '\d{3}'

You have to add another attribute to make the compiler understand that the idx is ahving a regex expression so the below is to be added next :

matching:idx='regex'

Great, it worked. Thanks much!

1 Like

It is resolved now by using
matching:idx=‘regex’

1 Like

Hi,

It is again not working today.

Can you please suggest any possible reason?

@neha.verma ,

The Regex Expression is wrong.

We mention Either \d+ or \d{3}.

+ would mean one or more match of the Preceding character.
{3} specifies exactly 3 digit match.

Check more on Regex Expressions below :

I tried idx=‘???’ as well and this was working last time as it is a 3 digit number.

I tried with \d+ as well, any more suggestions?

@neha.verma ,

We would need to understand what are the possible values the idx can have for your case or scenario.

Could you indicate the element and check what value it would have at different scenarios ?

Sure, this could be any 3 digit number like 134, 401 etc. It is a checkbox whose idx value could be any 3 digit number.

I also feel that the problem is not my regular expression but somehow, the regular expression is not working and it worked yesterday :frowning:

@neha.verma ,

Do confirm when it is failing what is the value of the element. So we can confirm if the regex works properly.

As you have mentioned 3 digits, The Regex Expression should be \d{3}. This would fail if the idx value is less than 3 digits or more than 3 digits.

@supermanPunch The idx value in my current case is 401 and the regular expresion ‘???’ or \d{3} is failing

@neha.verma ,

Could you use UiExplorer and indicate the Element again and check what is the difference between the Selector that you have used and the Current Indicated element’s selector ?

Ok, let me try. But when I click ‘Open in UI Explorer’, nothing happens. Do I need any package for this?

Edit: It opened now, thanks.

@supermanPunch Please help, I don’t see any difference in the locators that I am using and the ones displayed in UiExplorer

Why my regular expression could not be working?