Regular expressions
NeoLoad includes the Apache Jakarta ORO regular expressions, described in the Jakarta website, for handling Perl5-compatible regular expressions.
Regexes may be used within NeoLoad to define:
-
validations, described in Global validation: the request is valid if the content matches or contains the regex
-
variable extractors, described in Variable extractors: extracts a value from a request response and assigns the value to a variable.
This guide is not intended as a comprehensive guide to regular expressions. For more information about common cases, see Quick reference, Common errors & tips, and Examples.
Use regular expressions
Regular expressions are used to find substrings matching a pattern.
You can consider the following text as an example: The value is: 45675
You can perform two kinds of operations on the text:
-
test whether the text contains "
The value is: <a number>
" , as when defining a content assertion. In this case, the regex would be:The value is: \d*
-
extract the numerical value from the text, as when defining a variable extractor. In this case, the regex would be:
The value is: (\d*)
The parentheses define a group. Here, you may refer to this group value using "$1$
", as the expression only contains one bracketed group. When several groups are defined, use "$index$
", whereindex
id the group number in order of appearance from left to right.
Useful links
For tutorials and examples, see http://www.regular-expressions.info/.
NeoLoad can test the regexes to be used. Regexes may also be tested with the Regex Coach (http://www.weitz.de/regex-coach), a comprehensive freeware tool.