I would like to extract the last occurence of regular expression in Jmeter. I used Regular Extractor expression to do this, but I can't got the last occurence.
I tried this :
Then in my script I used ${expression} variable
I've tested expression_matchNr but it give me the number of match.
What should I put in "Match No:" ?
Thanks in advance
The regular expression may match multiple times. Use a value of zero to indicate JMeter should choose a match at random. A positive number N means to select the nth match. That's all about options of Regular Expression Extractor.
The single-line (? s) and multi-line (? m) modifiers are normally placed at the start of the regex. would match Match ExAct case or arbitrary case as well as Match ExAct case or ARBitrary case, but not Match exact case or ArBiTrARY case.
Regular Expression Extractor is a post processor (execute after the response arrives) and it is always added under a sampler whose response contains dynamic value(s) and you need to capture and pass that dynamic value(s) in the next request (where required).
Template: Templates in JMeter are references or pointers to the groups. As we have explained earlier, a regex may have more than one group — which means it allows us to specify which group value to extract by specifying the group number as $1$ or $2$ or $1$$2$ –which means extract both groups).
If you have the following output:
expression=foo
expression_1=foo
expression_2=bar
expression_3=**what you looking for**
expression_matchNr=3
You can use JMeter's __V function to get value of expression_3
variable
As per function's description:
For example, if one has variables A1,A2 and N=1:
${A1}
- works OK${A${N}}
- does not work (nested variable reference)${__V(A${N})}
- works OK. A${N} becomes A1, and the __V function returns the value of A1So in your case the function, returning last match no matter how many matches are will look like:
${__V(expression_${expression_matchNr})}
See How to Use JMeter Functions post series on what else can be done with functions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With