且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

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

更新时间:2022-10-31 19:14:35

使用单个表达式-<data xsi:type="soapenc:string">(.+?)</data>-获取所有匹配项.
如果存在多个匹配项,则jmeter将根据您要提取的变量名称为每个匹配项生成特定的变量-如refName_N:您的案例中的myAnotherID_1,myAnotherID_2,...,myAnotherID_N.
然后,您可以通过相应的变量(示例中的myAnotherID_1)引用所需的值.

Use the single expression - <data xsi:type="soapenc:string">(.+?)</data> - to get all the matches.
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.
Then you can refer required value via corresponding variable (myAnotherID_1 in your example).

  • 查看正则表达式提取器参考以获取匹配号说明.
  • 查看此帖子有关使用正则表达式提取器提取和访问一批值
  • 您还可以将调试采样器JMeter Variables = true一起使用,以查看全部提取一批值时生成的变量.
  • 查看这篇文章,可在不使用ForEach Controller的情况下循环浏览多个RegExp Extractor输出值.
  • 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.
  • Look into this post for looping through multiple RegExp Extractor output values without ForEach Controller.

希望这会有所帮助.