Forum Discussion

jozef's avatar
jozef
New Contributor
17 years ago

Regular expression in contains assertion

Hi,

I'm having some trouble using a regular expression for a 'Contains' assertion (SoapUI Pro 2.0.2). No matter what I specify for the regular expression, it never matches and the assertion fails. Even '.*'  does not match, which suggests a bug I think.
  • omatzura's avatar
    omatzura
    Super Contributor
    Hi Jozef

    thanks for your post! By defaul, the "." sign does not match line-breaks, so unless your response is just one long line, the ".*" wont work. You should prefix the expression with "(?s)", which tells the regex processor to include line-breaks (see http://www.jdocs.com/javase/7.b12/java/ ... ttern.html for more info on this).. so if you enter

    (?s).*

    you should get a match for anything..

    hope this helps!

    regards,

    /Ole
    eviware.com
  • jozef's avatar
    jozef
    New Contributor
    Thanks for the quick reply. I took a look at the pattern syntax on the page you mentioned but missed the (?s) expression. Maybe a small example in the SoapUI documentation on Contains assertions would be nice, even if it is just (?s).*

    It would've saved me some time
  • omatzura's avatar
    omatzura
    Super Contributor
    Hi Jozef,

    ok, we'll do that :-)

    regards,

    /Ole
    eviware.com