Over a million developers have joined DZone.

Load Test Correlation With JMeter's Regular Expression Extractor

DZone 's Guide to

Load Test Correlation With JMeter's Regular Expression Extractor

Learn how to use JMeter's Regular Expression Extractor for smooth automated load testing.

· Performance Zone ·
Free Resource

In today’s world, we have to deal with various system behaviors while communicating with one another. In most cases, to carry on with test scenarios, we need to fetch dynamic responses from preceding requests and pass it to the subsequent ones. Simply parsing and passing the needed data to the next caller provides a smooth transition during the test execution process (Load Test Correlation).


Since load/stress testing scenarios are based on mutual interactions between the client and remote, the need for correlation is a technical state every performance tester encounters at some point. To establish a strong bond with your test flow, JMeter comes with a handy feature: Regular Expression Extractor under Post Processors.


Reliability of your tests depends on the frequency of buggy occurrences, how robust your design is and how ready you are for unexpected situations.

When Using Static Parameters Is Not Enough…

After spending some time and going through the basics of JMeter, it is inevitable not to get stuck with handling dynamic data in your complex scenarios. At this very point, correlation kicks in.

Getting the data parsed from the response on the fly and passing it to the next request, plays a vital role in your test flow. Jmeter supports correlation with its “Regular Expression Extractor” which provides smooth data transition by using regular expressions and applies the parsed data on another sampler in our flow.

Why Regular Expressions?

Regular expressions are a set of symbols & characters which are used to build a pattern to match character combinations in strings. Regular expressions are very popular and used widely in programming languages and very easy to get used to.

JMeter’s regular expressions are provided by Jakarta ORO framework based on Perl5 Regex Engine. There are many great tutorials, websites, and articles about it, so take your time and you should be writing your style of patterns in no time.

How JMeter Handles Correlation

JMeter’s Regular Expression Extractor helps us fetch any portion of data from the response by using regular expressions. Since applying the regular expressions on the response is a post process, this explains why Regular Expression Extractor is located under Post-Processors.

After matching the set of characters by using the Extractor, this value is set to a variable for future use on another sampler.

Getting to the Point...

Regex Extractor has a few options we need to know in advance.

A. Apply To:

Main Sample -produced by the primary request- and/or Sub Sample -produced by any request made related to the primary request- can be picked to apply the regular expression.

B. Response Field to Check:

A Regex can be applied to a part of the response message such as header, body etc…

C. Reference Name:

This is the name of the variable which stores the matched data. This variable can later be called from another request by simply using the following syntax: ${}

D. Regular Expression:

Your regex pattern goes here.

E. Template:

Regex may have more than one group. Templates – regex group index- are used to match the group that contains the data.

F. Match No:

Multiple matched sets might return for a regex pattern. By setting the match number, data-to-store is chosen from the result set and set to the variable -reference name-.

G. Default Value:

If there is no match for the regex, then the default value is set to the variable.

If you wonder how this technique is applied in practice, please go ahead and take a look at the following link:

HTTP Live Streaming Performance Test

Happy load testing…

jmeter ,stress testing ,load testing ,performance ,tutorial

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}