Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regular Expression Extractor in Jmeter

Tags:

regex

jmeter

I have this response in HTTP request as below

href="index.php?module=Meetings&action=DetailView&record=ed51c2d9-1958-bd61-cce1-509d30ccd4ac">

I want to get the value of "record", but when I set

Regular Expression : record=(.+?)

only "e" is returned. What do I need to do instead?

like image 484
user1813000 Avatar asked Nov 09 '12 18:11

user1813000


People also ask

What type of element is a regular expression extractor?

Let us understand the use of Regular expressions in the Regular Expression Extractor—a Post-Processor Element by writing a test plan. This element extracts text from the current page using a Regular Expression to identify the text pattern that a desired element conforms with.

What is the use of boundary extractor in JMeter?

It allows you to set a left boundary value for the string being verified. “Right boundary” does the same as the previous field but from the right side. “Match No.” allows you to set an index for the found value if many values were found by the given criteria.

Can we extract value from request body in JMeter?

The value(s) which is extracted can be stored in any variable and can be a reference in any further request in the test plan. Values can be extracted from the response body, header, URL, response code, and other provided fields when you add this processor.

What is the use of JSR223 postprocessor in JMeter?

The JSR223 postprocessor allows you to use precompiled scripts within test plans. The fact that the scripts are compiled before they are actually used brings a significant performance boost compared to other postprocessors.


1 Answers

Well the regular expression consumes as little as possible (due to the ?). Hence, it is satisfied after taking in the first character. You should probably rather make it greedy and restrict the possible characters (so that it cannot go past the end of the parameter):

record=([a-f0-9-]+)

If you do not know which characters are allowed as the parameter's value, you could also say, consume everything but ampersands and quotes:

record=([^"'&]+)

Depending on where you use it, you might need to escape one of the quotes with a backslash.

like image 141
Martin Ender Avatar answered Sep 28 '22 07:09

Martin Ender