Forum Discussion

rajehari's avatar
rajehari
New Contributor
11 years ago

Regular expression feature in Contains Assertion

Hi,

Can anyone let me know on how to use the regular expression feature in Contains Assertion with examples.

Thanks,
Raji
  • rajehari's avatar
    rajehari
    New Contributor
    Hi Thanks..

    I did check that, but it has only one example to use the regular expression. I want to know the other possible expressions which can be used in this.
  • PaulDonny's avatar
    PaulDonny
    Regular Contributor
    After doing some research here is my findings:

    It uses a matches() technique, not a find() technique. Personally for this, find() seems like it would be far better but either way works. Since it is using matches you will likely want to tell it to use a multi-line match "(?s)" this was the cause for a lot of my issues with this.



    Personally, I would recommend just using the script assertion and use the regex there VIA groovy. But just remember, it's a matches() type of identifier.

    This url has a great regex tester that should help you find your regex matches. Just copy and paste the XMl into one of the input fields and then test your regex there. Again, it HAS to match with the regex assertion.
    http://www.regexplanet.com/advanced/java/index.html