Ask a Question

Regular expression in contains assertion

jozef
New Contributor

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.
3 REPLIES 3
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
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
Super Contributor

Hi Jozef,

ok, we'll do that 🙂

regards,

/Ole
eviware.com
cancel
Showing results for 
Search instead for 
Did you mean: