How can we use regular expressions within selectors in uipath? (Except the wildcards)

How can we use regular expressions within selectors in Uipath? This does not include the wildcards.

2 Likes

how are planning to create regular expressions without wildcards…?

@Pranav_Nikam

As I understand, you can use any code that will return a specific string.

This means that you can construct your selector with a variable like this:
"<webctrl aaname='"+System.Text.RegularExpressions.Regex.Match("Name 123","\w+").ToString+"' tag='A' />"

This would return the following selector:
"<webctrl aaname='Name' tag='A' />"

EDIT from the future.
Since 2019.5, it is possible to simply add a variable directly from the selector editor without string concatenation. You simply have to place your cursor on property value, like so (with a left click):
image
and then right click it to get the drop down menu:
image

The variable will be placed in such a way: {{variableName}}, thus:
"<webctrl aaname='{{variableName}}' tag='A' />"

Please remember that you will need to give the variable a default value in the Variables pane for it to correctly validate your selector in the Selector Editor.

4 Likes

As of now there are only 2 wildcards. But regular expression has many symbols and types. So I am asking how can we use those in selectors?

Suppose we only want to go for numerical string like [0-9]*. So how an we do the same within selectors?

Indeed, for more advanced construction you can use custom premade variables that you include in your selectors. For simple variations the two available wildcards should be enough.

Regex expression can be used in selectors as shown in the below link