Regular expressions
In This Appendix
Overview Quick reference Examples Common errors & tips Links to regex resources Links to regex testers Overview
Introduction
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 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 and Examples. See Links to regex resources.
For more information about testing regexes, see Links to regex testers.
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 brackets define a group. Here, we may refer to this group value using "$1$", as the expression only contains one bracketed group. When several groups are defined, use "$index$", where index id the group number in order of appearance from left to right.
Home