Wednesday 11 February 2015

Apply Regular Expression on a Jmeter Variable

There are few scripting areas where jmeter has upper hand over other load test tools, below is one such area.

In majority of load test tools you cannot apply a Regexp on a defined variable, in such cases we need to write some string functions which is a tedious job, but in jmeter you can easily achieve it by using Regular Expression Extractor(see below).


Step 1: Creating a jmeter variable by extracting a value to "cExpandContext1"



Step 2: To apply Regexp on above variable
  a) Add a Regular Expression Extractor to a request
  b) Select Jmeter Variable option under "Apply to" and input the variable name(i.e cExpandContext1)
  c) Now add extraction rule as we do for normal extractions (see below)


No comments:

Post a Comment