REQUEST: XPath regex operator for escaping the string
Posted: Mon Aug 12, 2013 5:16 pm
When using variables in a regular expression in the XPath for a repository object, the variable is not being escaped.
My variable in this instance is a US phone number "(NNN) NNN-NNNN".
The XPath is "//select[#'phone']//option[@innertext~$phoneNumber]"
The XPath is seeing the parenthesis as a regular expression group, and, in this case, it should not.
There is no way to tell Ranorex to escape the variable, and I must use RegEx because the innertext actually might contain more than the phone number, but will ALWAYS contain AT LEAST the phone number, such as:
"Work - (NNN) NNN-NNNN"
and
"(NNN) NNN-NNNN"
The problem here is that I have other people working on the data sets for this test and I can't expect them to remember to escape the strings in the database.
It would be nice if there was another operator that tells the XPath to treat the sequence as an escaped literal.
EDIT TO ADD: How about "~@" or "@~"? .NET uses "@" for explicit literal strings.
My variable in this instance is a US phone number "(NNN) NNN-NNNN".
The XPath is "//select[#'phone']//option[@innertext~$phoneNumber]"
The XPath is seeing the parenthesis as a regular expression group, and, in this case, it should not.
There is no way to tell Ranorex to escape the variable, and I must use RegEx because the innertext actually might contain more than the phone number, but will ALWAYS contain AT LEAST the phone number, such as:
"Work - (NNN) NNN-NNNN"
and
"(NNN) NNN-NNNN"
The problem here is that I have other people working on the data sets for this test and I can't expect them to remember to escape the strings in the database.
It would be nice if there was another operator that tells the XPath to treat the sequence as an escaped literal.
EDIT TO ADD: How about "~@" or "@~"? .NET uses "@" for explicit literal strings.