[英]In JMeter how can I capture multiple (varying) values of a regular expression?
I need to parse a html page that can contain multiple (unspecified how many) links. 我需要解析一个可以包含多个(未指定数量)链接的html页面。 Here an example (pseudo html):
这是一个示例(伪html):
<a href="../entrygroups/GROUPIDENTIFIER/3">edit</a>
[...]
<a href="../entrygroups/GROUPIDENTIFIER/7">edit</a>
[...]
<a href="../entrygroups/GROUPIDENTIFIER/12">edit</a>
[...]
<a href="../entrygroups/GROUPIDENTIFIER/16">edit</a>
I am basically just interested in the numbers 3
, 7
, 12
, 16
of the url. 我基本上是在数字只是感兴趣
3
, 7
, 12
, 16
的url。
Is there a way to put those values into some sort of array and loop over them (in a for each kind of way). 有没有一种方法可以将这些值放入某种数组中并在它们上循环(以每种方式的一种)。
Is this possible and if so, how would I do this? 这可能吗?如果可以,我该怎么做? I looked at the regular expression extractor but it seems that that one can only assign a fixed set of groups to a fixed set of variables.
我看了正则表达式提取器,但似乎只能将一组固定的组分配给一组固定的变量。
Actually RegEx extractor is able to do exactly what you want, if you specify Match No. field with less than 0, eg -1 : 实际上,如果您指定小于0(例如-1)的“匹配号”字段 ,则RegEx提取器可以完全满足您的要求。
As a result, you will get N variables (using your input as example): 结果,您将获得N个变量(以您的输入为例):
id_1=3
id_2=7
id_3=12
id_4=16
There also will be variable which has a count of matches: 也将有一个具有匹配项计数的变量:
id_matchNr=4
Extract the values using Regular Expression Extractor configured like: 使用配置如下的正则表达式提取器提取值:
Add ForEach Controller configured like: 添加配置如下的ForEach Controller :
Refer the "GROUPIDENTIFIER" value as ${current_edit}
where required 在需要时,将“ GROUPIDENTIFIER”值引用为
${current_edit}
See Using Regular Expressions in JMeter guide for another example of looping through all links found in the page with the Regular Expression Extractor and ForEach Controller. 有关使用正则表达式提取器和ForEach控制器在页面中找到的所有链接进行循环的另一示例,请参见JMeter指南中的使用正则表达式 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.