0

I have a phone Number RegEx value which I wanted to assert. I extracted the value and tried to assert against the expected RegEx like ^(((\\+|00)?63)|0)(81|9\\d){1}(\\d){8}$.

But the problem is JMeter does not recognize the extracted RegEx and the provided one as same! Is there some extra JMeter function that I'm supposed to use to assert RegEx?

enter image description here

*I found the mistake I made. I did not uncheck "Match as regular expression" because of which the response was not matching.

Epilogue
  • 3
  • 5
  • For which values did it not work? – The fourth bird Nov 19 '18 at 07:13
  • @Thefourthbird, one I stated in my description and screenshot- '^(((\+|00)?63)|0)(81|9\d){1}(\d){8}$' – Epilogue Nov 19 '18 at 07:42
  • @Thefourthbird, I was trying to verify if the regex is alright or not. So I was actually asserting the regex against itself. – Epilogue Nov 19 '18 at 07:46
  • I have a token which generates unique and dynamically for which I have a regex and I want to assert with the actual value which is coming in the listener which is the same token dynamic for which the regex is not validating in the expected text area. – Rahul N Jul 19 '20 at 19:43
  • @Epilogue - Can you check this please - https://stackoverflow.com/questions/65149040/is-it-possible-to-use-wild-cards-in-json-validation-or-ignore-some-values-in-jso – Manu Chadha Dec 04 '20 at 19:17

1 Answers1

0

If you want to verify the regular expression using Response Assertion be aware that:

  1. In Substring and Equals mode it treats "Pattern" as a normal string
  2. In Matches and Contains mode it treats "Pattern" as aPerl-5 style regular expression therefore you need to escape all the special characters with a back slash.

Given you use Matches Pattern Matching rule you should be validating your regular expression in order to match itself like:

\^\(\(\(\\\\\+\|00\)\?63\)\|0\)\(81\|9\\\\d\)\{1\}\(\\\\d\)\{8\}\$

Check out How to Use JMeter Assertions in Three Easy Steps article for more information on applying custom failure criteria using JMeter Assertions.

Dmitri T
  • 159,985
  • 5
  • 83
  • 133
  • Thanks for the reply. This is a good alternative of simple JSON assertion. Though, I found the mistake I made. I did not uncheck "Match as regular expression" because of which the response was not matching. – Epilogue Nov 20 '18 at 04:55