...
Wiki Markup |
---|
*Answer:*JMeter includes the pattern matching software \[http://jakarta.apache.org/oro/ Apache Jakarta ORO\]. There is some documentation for this on the Jakarta web-site. There is also documentation on an older incarnation of the product at \[http://www.savarese.org/oro/docs/OROMatcher/index.html 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. O'Reilly sell a book called "Mastering Regular Expressions" by Jeffrey Friedl which will tell you all you need to know (and a lot more) about regular expressions. There are a couple of chapters available on their web-site covering REs in Java and .NET, and the Java chapter has a \[http://www.oreilly.com/catalog/regex2/chapter/ch08.pdf section on ORO (PDF)\] - worth a look. |
It is worth stressing the difference between "contains" and "matches":
- "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 Perl modifiers ismx etc if there is no trailing /? The solution is to use Perl5 extended regular expressions, i.e. /abc/i becomes (?i)abc
For a useful Regex tester, see http://weitz.de/regex-coach/
See also RegularExpressions. for more details and examples
I want to use “Monitor Results” of JMeter
...