I want to use regular expression in a selector.I want to match spaces after innertext. Lets say we have 2 buttons with innertext=’ button ’ and innertext=’ button test ’ I want to use innertext in selector so when I can pass innertext as a parameter and when button is passed its selecting the correct control. if I am using argument called in_InnertText, how to allow only spaces after the text? in the following, how to use a regular expression after in_InnertText?
If I use button , selector doesn’t work because it matchs both.I need to pass inner text as a parameter in_Innertext and use a regular expression to match spaces so when I pass “button” it will match the first and “button test” it will match the second
If it were me, I would have the in_InnerText variable with exactly what you want. This means the regex should be done before it gets to the selector portion. Separating it out makes it more clear what is happening for debugging and for future people looking at the code.
To do this, just manipulate in_InnerText before hand with regex. I’m still not 100% clear what you’re trying to do, but \s will grab any white-space characters. Use an earlier if statement to decide whether to assign in_InnerText to button vs button test and you can simply pass in the one variable into your selector exactly the way you’ve written it: innertext='"+in_InnertText+"'