Reputation: 767
any one can please give me the simple example on how to use regular expressions in JMeter.
Upvotes: 2
Views: 2282
Reputation: 57
Here is a simple regular extractor example used with primefaces — link to prnt.sc image
You get the viewState value and store it in jsfViewState. Later on you can get it simply by typing ${jsfViewState} anywhere you need.
Upvotes: 0
Reputation: 7707
Start by reading the manual: http://jmeter.apache.org/usermanual/component_reference.html#Regular_Expression_Extractor
You'll want a tool to help you write a regex. Personally, I'm a fan of RegexCoach.
To write your expression, you'll need the source code. You can grab this from the browser, or from within Jmeter using Tree View.
The example below scans the body of the response, looking for a number within ANY random ID tag and assigns to the variable "someVariableName":
Name: My Regex
Apply to: Main Sample
Response Field to check: Body (unescaped)
Reference Name: someVariableName
Regular Expression: <id>(\d+?)</id>
Template: $1$
Match No.: 0
Default Value: Regex Failed
Upvotes: 3