Page 1 of 1

Strip characters on a match

Posted: Fri May 15, 2015 1:20 am
by jackrabbit
I need to find an object using a text value from a menu. The problem I have is that the menu labels sometimes contains the AMPERSAND character. My problem is that the menu system no longer underlines the letter from the menu item.

In other words, if the menu item shows the option "Print", the text attribute that I need to look for may me "Print", "&Print", "P&rint", "Pr&int", "Pri&nt" ou "Prin&t", there is no way for me to guess which because the UNDERLINE is no longer visible with my screen interface.

Of course, I could go into the program source code, and examine the actual text, but this is not possible for me.

Right now, the only way that I can match my menu item is with the following RxPath:
menuitem[@text='Print' or @text='&Print' or @text='P&rint' or @text='Pr&int' or @text='Pri&nt' or @text='Prin&t']

Of course I could also use:
menuitem[@text~'&?P&?r&?i&?n&?t']

I wish I could trim the AMPERSAND from the text string before doing a match:
menuitem[replace(@text,'&','')='Print')

Is there another way to match a string containing a specific character in any location?

Re: Strip characters on a match

Posted: Fri May 15, 2015 2:35 pm
by krstcs
Unfortunately, the first two ways you discussed are really the best ways to do it if you don't know exactly what version you are looking for.

The other thing you might do is see if there is another attribute of the menu item that could be used instead of @text, preferably one that doesn't have any special/dynamic characters.