Using Regular Expression Extractor in JMeter

Profile picture for user devraj

A regular expression, regex or regexp (rational expression) is a sequence of characters that define a search pattern. 

You can control what to extract from a server response using regular expression syntax. You can use Regular Expression Extractor to extract url paths, html responses, xml responses and json responses. 

For site that use CSRF (Cross-Site Request Forger) to prevent against malicious attacks, a token is attached to each user's session which is sent along with every request from the user. Therefore each user has their own unique token and if we try to use same token for 2 users, it throw an error that request is denied.

Below are the steps cover to use the Regular Expression Extractor component in JMeter to extract server responses:

Step 1: Launch JMeter

Step 2: Right click on Test plan and go to Add->Post Processors->Regular Expression Extractor

Step 3: To avoid request denied error and generate unique token Select Response Header and Enter following details

Reference Name: token
Regular Expression: XSRF-TOKEN=(.+);
Template: 1$
Match No: 0
Default Value: NOT_FOUND

Tags