If you want to do this using scripting the relevant code would be something like:

import java.util.regex.Pattern;
import java.util.regex.Matcher;

 responseData = prev.getResponseDataAsString();
log.info("Response Data: " + responseData);

Pattern p = Pattern.compile("(\d+)");
Matcher m = p.matcher(responseData);

int counter = 1;
while (m.find()){
   log.info("var_"+ counter + "=" + m.group(1));
   vars.put("var_" + counter, m.group(1));

It will the following :


You will be able to access them as ${var_1} and {var_2} later on.


JMeter Scripting Extract Values Regex

In the above demo prev stands for parent SampleResult, this way you can have access to the Dummy Sampler response data. Pattern and Matcher are “normal” Java classes.

Also be aware that starting from JMeter 3.1 it is recommended to use JSR223 Test Elements and Groovy language for scripting so consider migrating to JSR223 PostProcessor and Groovy language. The main reason is that Groovy has much better performance comparing to Beanshell, moreover it is more modern, compliant with latest Java versions and has some nice features on top.

Source link https://sqa.stackexchange.com/questions/34814/for-the-provided-string-a-href-statement-phpmonth-07ampyear-2018-how-to


Please enter your comment!
Please enter your name here