Wildcard for spaces only

Hi!
I think it would be really useful to have a wildcard that only allows spaces.
Let’s say we have a form field with a “Name” tag. Sometimes, aaname property have spaces before and after (instead of ‘Name’, it appears as ’ Name '). If we use *, it could cause problems if there is another field before containing ‘Name’ (For example ‘Company Name’).

Well, you could use advanced Regex selectors. In this example the expression captures only elements that have Name in them, but not Company Name.

image

1 Like

HI @Damian_Schapiro,

As @AndyMenon mentioned, the regex selectors work really well and I would suggest you do use them when you are faced with such boundary cases.

You can read more about using regex based selectors here : #FeatureBlog - 19.10 - Using regular expression (Regex) in the selector attributes

In the case you mentioned

<wnd app='chrome.exe' cls='SOMEValue'  aaname='Name|Name\s|\sName' matching:aaname='regex'  />
<wnd SOMESELECTOR='1148' />

This will work for aaname with Name, Name+SPACE, SPACE+Name

3 Likes

Thanks for posting that Link here @jeevith . I have bookmarked it so that I can find it the next time. :slight_smile: :+1:

1 Like

Thank you so much! How would I add this code to the selector?
Is aaname=‘/"\sName\s"|’\sName\s’ /g’ matching:aaname=‘regex’ ok?

Can I use a variable inside the regex code? Like:
aaname=‘/"\s*{{variable1}}\s*"|’\s*{{variable1}}\s*’ /g’

It should work if you put the whole thing inside of a variable.

That way you don’t distribute the expression between a variable and the selector.

Thanks

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