Forum Discussion
Hi Rao,
Thanks for the quick reply, appreciate your time.
But how would that work in my example if i want to use the regular expressions?
For example, apparently a dot should match any character or \d should match any digit. But if i do the following it doesn't work:
Response:
<ns1:RandomNumber>234</ns1:RandomNumber>
Contain Assertion:
<ns1:RandomNumber>...</ns1:RandomNumber>
or <ns1:RandomNumber>\d\d\d</ns1:RandomNumber>
- arunbharath5 years agoContributor
Hi tester213243
Can you try <ns1:RandomNumber>[1-9][1-9][1-9]</ns1:RandomNumber> . hope it works
- tester2132435 years agoNew Contributor
Hi arunbharath
No unfortunately that doesnt work either.
There are many numbers in my response but if i just create a contain-assertion with [1-9] it fails.
Also if i check the box 'Use token as regular expression'.
- nmrao5 years agoChampion Level 3
Instead of contains, use XPath assertion and provide the node, then use regular expression. If you are expecting 3 digits, try like
\d{3}
- nmrao5 years agoChampion Level 3
There is an example in the documentation for the same
In your case, use xpath assertion with
XPath expression as
matches(//*:RandomNumber, '\d{3}')
And Exprected Result as
true
NOTE: ignore namespace from the image below and use your name spaces by clicking on declare.
Related Content
- 9 years ago
- 8 years ago
- 5 years ago
Recent Discussions
- 7 hours ago
- 17 days ago