Selector based on variables and regex

Hello

I am using the same workflow for multiple objects, depending on the name of the object, the ‘text’ in the selector will change

Here is the list of the objects: [ZLS;ZVV;ZMM,ZA?] I just use ‘text’ as a variable for each of the elements of the array and replace it in the selector

Now the issue is with the last one which could either be ZA1 or ZA2.

Using ZA? didn’t work because there are other selectors such as “ZAR” which I do not want

So I would like to add something to my selector so that the last character is a digit while still keeping a general selector hat would work for the other ones that don’t have digits in the end

Here is my selector : sap id=‘usr’ /><sap text=myVariable type=‘GuiLabel’ check:text=myVariable /

Is there any way to do this ?

Hi @adext

Try this:

sap id=‘usr’ /><sap text=‘"+myVariable+"[0-9]’ type=‘GuiLabel’ check:text=‘"+myVariable+"[0-9]’ /

what about the other ones of the list that do not have digits in the end ? is it possible to have this only for “ZA1” and “ZA2” ?

a regex selector works like this:
https://docs.uipath.com/studio/standalone/2023.4/user-guide/regex-search

we have some doubts on the attributes as it is a SAP selector

<sap text='ZA1|ZA2' matching:text='regex' type='GuiLabel' />

and we can dynamize it by
https://docs.uipath.com/studio/standalone/2023.4/user-guide/dynamic-selectors

<sap text='{{myPattern}}' matching:text='regex' type='GuiLabel' />
1 Like

Hi @adext ,

Here, we are considering that each value is being looped and substituted in the Selector. For the last case, we can change the value to ZA., so the updated list will be as below :

["ZLS","ZVV","ZMM","ZA."]

In the Selector we could modify it as below :

<sap id='usr' /><sap text={{myVariable}} type='GuiLabel' matching:text='regex' />

Could check with the post below on using Regex in Selectors :

1 Like

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