简体   繁体   English

如何在JMeter中使用正则表达式提取器提取某些值?

[英]How to extract certain values using regular expression extractor in JMeter?

In the case where I have two identical tags and identical attributes and the only difference is the value, how can I extract the second one? 如果我有两个相同的标签和相同的属性,唯一的区别是值,我该如何提取第二个?

<data xsi:type="soapenc:string">0</data>
<data xsi:type="soapenc:string">1</data>

I have tried doing the followings. 我尝试了以下操作。

<data xsi:type="soapenc:string">0</data><data xsi:type="soapenc:string">(.+?)</data>

And assign the value to myID. 并将值分配给myID。 But when I put in ${myID} in the script, it is using the string "${myID}" instead of the actual value. 但是,当我在脚本中放入$ {myID}时,它使用的是字符串“ $ {myID}”而不是实际值。 Is it that the extraction not working? 是提取不起作用吗? Or do I need to use a different variable for it? 还是我需要使用其他变量?

I have a different sampler where I have only one tag. 我有一个不同的采样器,其中只有一个标签。 For example, 例如,

<data xsi:type="soapenc:string">0</data>

When I do, 当我做,

<data xsi:type="soapenc:string">(.+?)</data>

and assign to myAnotherID, I can use ${myAnotherID} and the value would be used in the script. 并分配给myAnotherID,我可以使用$ {myAnotherID},该值将在脚本中使用。

So, why is it that ${myID} does not return the value? 那么,为什么$ {myID}不返回值呢?

Thanks in advance, Monte 在此先感谢,蒙特

Use the single expression - <data xsi:type="soapenc:string">(.+?)</data> - to get all the matches. 使用单个表达式- <data xsi:type="soapenc:string">(.+?)</data> -获得所有匹配项。
If there are more than one match jmeter will generate specific variables for each match, based on the variable name to which you are trying to extract - like refName_N : myAnotherID_1, myAnotherID_2, ..., myAnotherID_N in your case. 如果有多个匹配项,jmeter将根据您尝试提取的变量名称为每个匹配项生成特定的变量-如refName_N :您的案例中的myAnotherID_1,myAnotherID_2,...,myAnotherID_N。
Then you can refer required value via corresponding variable (myAnotherID_1 in your example). 然后,您可以通过相应的变量(示例中的myAnotherID_1)来引用所需的值。

  • Look into Regular Expression Extractor reference for Match Number explanation. 查看正则表达式提取器参考以获取匹配号说明。
  • Look into this post about extracting and accessing batch of values using Regular Expression Extractor. 看看这篇文章有关提取和访问批量使用正则表达式提取值。
  • You can also use Debug Sampler with JMeter Variables = true to see all the variables generated upon extracting batch of values. 您还可以将Debug SamplerJMeter Variables = true以查看提取一批值时生成的所有变量。
  • Look into this post for looping through multiple RegExp Extractor output values without ForEach Controller. 在没有ForEach Controller的情况下,请查看这篇文章以循环遍历多个RegExp Extractor输出值。

Hope this helps. 希望这可以帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用正则表达式提取器提取jmeter中的Json值? - How to extract the Json values in jmeter using regular expression extractor? 如何使用正则表达式提取器在jmeter中提取json响应数据? - how to extract json response data in jmeter using regular expression extractor? 如何从使用 JMeter 中的正则表达式提取器提取的多个值中提取单个 Header 值? - How to extract single Header value from multiple values extracted using regular expression extractor in JMeter? 如何在jmeter中使用常规提取器提取GUID - How to extract GUID using regular extractor in jmeter 使用正则表达式提取器从 jmeter 中的 url 中提取值 - Use Regular Expression extractor to extract values from url in jmeter JMeter - 使用正则表达式提取器提取表单的操作属性 - JMeter - Extract Form's action attribute using Regular Expression Extractor 如何从jmeter响应中提取正则表达式提取器? - how to extract Regular expression extractor from jmeter response? 如何使用正则表达式提取器从jmeter中的响应中提取值 - how to use Regular expression extractor to extract value from response in jmeter Jmeter 正则表达式提取器提取输入值 - Jmeter Regular Expression Extractor to extract an input value 如何使用正则表达式提取器从JMeter中的字符串中提取固定数量的字符? - How to extract fixed number of characters from string in JMeter using regular expression extractor?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM