JMeter includes the pattern matching software
Apache Jakarta ORO
There is some documentation for this on the Jakarta web-site, for example
a summary of the pattern matching characters
There is also documentation on an older incarnation of the product at
OROMatcher User's guide
, which might prove useful.
The pattern matching is very similar to the pattern matching in Perl.
A full installation of Perl will include plenty of documentation on regular expressions - look for perlrequick, perlretut, perlre, perlreref.
It is worth stressing the difference between "contains" and "matches", as used on the Response Assertion test element:
-
"contains" means that the regular expression matched at least some part of the target,
so 'alphabet' "contains" 'ph.b.' because the regular expression matches the substring 'phabe'.
-
"matches" means that the regular expression matched the whole target.
So 'alphabet' is "matched" by 'al.*t'.
In this case, it is equivalent to wrapping the regular expression in ^ and $, viz '^al.*t$'.
However, this is not always the case.
For example, the regular expression 'alp|.lp.*' is "contained" in 'alphabet', but does not match 'alphabet'.
Why? Because when the pattern matcher finds the sequence 'alp' in 'alphabet', it stops trying any other combinations - and 'alp' is not the same as 'alphabet', as it does not include 'habet'.
Note: unlike Perl, there is no need to (i.e. do not) enclose the regular expression in //.
So how does one use the modifiers ismx etc if there is no trailing /?
The solution is to use
extended regular expressions
, i.e. /abc/i becomes (?i)abc.
See also
Placement of modifiers
below.