Ask a Question

how to use properties wthin regular expressions for assertions?

Frequent Contributor

how to use properties wthin regular expressions for assertions?

I would like to parameterize a test-case because a date that has to be supplied as part of the reuest has to be within a valid range and thus can not be constant. So I defined it as project property (which hopefully one day will be assigned automatically once I am more familiar with soapUI's scripting...)


The response thus needs to be tested not against a constant string but against a regular expression (because I also want to ignore certain parts of the response) part of which should be the content of the same property that is used as argument of the request.


How can I have a property be inserted into a regular expression? If I just add the usual ${#Project#date} into the regular expression this obviosly does not work because $, #, etc. have special meanings inside a regexp. If I escape those characters, however, they are considered as literals. So, how can I have the property's value injected BEFORE the strin is used as regexp?


Hope I could make myself clear...


Valued Contributor



Not sure if this will help you with creating a your date within a given range using a script, but just incase I solved a problem like this previously in the following post:


In order to test that your response contains a date within a given range using a regex, I would try a Script Assertion:


1) Get the date from the response and hold it in a variable using a property expansion e.g. something like


 def dateToTest = context.expand('${#Project#date}')


2)  Next test the dateToTest variable against your regex using something like:


If (dateToTest=~searchStringRegex) { code if matched... }
For more on Groovy regex, go to


Is this on the right track to what you're after?




Author of SoapUI Cookbook

It didn't directly answer my question but gave me some indications, where to search on. So it helped. Thanks!

Ok, no problem 🙂




Author of SoapUI Cookbook
Showing results for 
Search instead for 
Did you mean: