import java.util.Random;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
String responseData = prev.getResponseDataAsString();
// log.info("the response data is : " + responseData);
Pattern pattern = Pattern.compile("<option value=\"(.+?)\">(.+?)</option>");
// log.info("pattern is : " + pattern);
Matcher matcher = pattern.matcher(responseData);
// log.info("matcher is :" + matcher);
while(matcher.find())
{
log.info("the cities are : " + matcher.group(1));
String extractedCity = matcher.group(1);
log.info("the extracted city is : " + extractedCity);
vars.put("Depart_city" , extractedCity);
}[log level output of the code](https://isstatic.askoverflow.dev/ANKbl.png)
我能够提取数据,但无法从结果中选择随机值并将其存储到 jmeter 变量中