Home > Performance Testing > JMeter > Extract data from Response in JMeter using Regular Expression Extractor

Extract data from Response in JMeter using Regular Expression Extractor

Regular expression extractor is a post processor component used to extract required data from the response body.

Consider an example where we want to extract ‘title’ value from the response body.

Extract title from Response body

Using ‘Regular Expression Extractor’ title value can be extracted.

Regular Expression Extractor Setup

Details of the fields used in above Regular Expression Extractor(RE):

  • Name given to the extractor is: Extract Title
  • Check Apply to: Main sample only radio Button. RE extractor will be applied only to the response from primary request.
  • Check Field to check: Body radio Button. RE extractor will be checking response present in the response body only.
  • title_value is the name of the created variable in which extracted value from regular expression will be stored.
  • <title>(.*)<\/title> it is the Regular Expression used to get the desired result.
  • Template: Sometimes regular expression contains more than one group. This allows us to get the group value to extract by specifying the group number. In our case we are using Group 1. Syntax: $1$.
  • Match No: Sometimes our regular expression matches to more than one response data. Using Match No we can specify which match we want to use. In our case we are using Match No: 1.
  • Default Value: In case Regular Expression does not match with the response data then variable ‘test_code’ will not be created. But if the default value is set and regular expression does not match with the response data then the variable will be set to default value which is specified in default value field. In our example default value is set to: notfound.

So using Regular Expression Extractor we can extract any desired field from the response body.

This Article is TAGGED in , . BOOKMARK THE permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">