[Tsung] question on regexp for dyn_variables

Craig Jolicoeur cpjolicoeur at gmail.com
Wed Jan 13 21:22:49 CET 2010


I'm a little unclear on the proper syntax for matches and
dyn_variables using regexp expressions with tsung.

The documentation gives an example of:

<request> <dyn_variable name="mytitlevar"
regexp="&lt;title&gt;\(.*\)&lt;/title&gt;"/> <http
url="/testtsung.html" method="GET" version="1.0"></http>
</request>


I'm unsure why the regexp is in the format it is.  For instance, why
are the match characters (the parenthesis) escaped with a backslash.
Wouldn't that mean to search for the literal parenthesis character
instead of using the paren as a match object?

Also, when trying to do a <match> on the server response, the
documentation does not say how to match against a regexp instead of a
standard string.  The docs simply say you can use a regexp, but what
is the syntax for doing so?  Do I do something like:

<match do="log" when="match">/regexp_here/</match>

Or what is the actual syntax?

I'm unable to figure this out.

I'm trying to match the following server response:

setCachedSessionKey('1234abcd')

to grab the session key value.

I've tried the following regexp and none seem to work

SessionKey\('(.*)'\)

SessionKey.{2}(.*).{2}

SessionKey.{2}\(.*\).{2}

What am I doing wrong?

- Craig


More information about the Tsung-users mailing list