Appendix A. Regular Expressions

Table of Contents

Overview
Introduction
Using regular expressions
Quick Reference
Special character definitions
Character classes
Pre-defined character classes
Examples
Extracting a URL parameter value
Extracting a Form Parameter Value
Extracting HTTP headers
Extracting miscellaneous values
Common Errors & Tips
Use of the question mark '?'
Brackets
Spaces
Multi-Line
Links to Regex Resources
Links to Regex Testers

Overview

Introduction

NeoLoad includes the Apache Jakarta ORO regular expressionsoftware for handling Perl5-compatible regular expressions.

Regexes may be used within NeoLoad to define:

  • content assertions: the request is valid if the content matches or contains the regex,

  • variable extractors: extracts a value from a request's response and assigns the value to a variable,

This guide is not intended as a comprehensive guide to regular expressions.

The Quick Reference and Examples sections should provide enough information for most cases. Please see the Links to Regex Resources section for links to fuller documentation and tutorials. You may also test your regexes with the tools listed in the Links to Regex Testers section.

Using regular expressions

Regular expressions are used to find substrings matching a pattern

Let's consider the following text as an example: The value is: 45675

We can carry out two kinds of operation 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 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.