Jmeter输出的正则表达式

时间:2017-02-07 13:24:39

标签: regex performance scripting jmeter beanshell

我得到了像

这样的输出

Jmeter Request Response

简单答复:

ticket_tax_dtls_id  tax_code    tax_amount_remitted tax_amount_p‌​roposed   tax_amount_a‌​pplicable 
667894  CN 140.0    null    140.0 
667895  US  232.0   null    232.0 
667896  YC  36.0    null    36.0 
667904  BP  56.0    null    56.0 
667905  XA 26.0 null    26.0 
667906  XF  30.0    null    30.0 
667914  AY  37.0    null    37.0 
667915  XY  46.0    null    46.0 
667916 XFHNL4.5 0.0 null    0.0

在Jmeter中。我需要使用正则表达式提取器捕获动态文件名并捕获所有变量并在请求中进一步传递它,如下所示。

[["key0",{"taxcode":"CN","remtAmt":"90.0","propAmt":"90.0","appAmt":"90.0","apcode":"","ticketTaxId":"677839"}],["key1",{"taxcode":"XA","remtAmt":"26.0","propAmt":"","appAmt":"26.0","apcode":"","ticketTaxId":"677840"}],["key2",{"taxcode":"XF","remtAmt":"90.0","propAmt":"","appAmt":"90.0","apcode":"","ticketTaxId":"677841"}],["key3",{"taxcode":"XFHNL4.5","remtAmt":"0.0","propAmt":"","appAmt":"0.0","apcode":"","ticketTaxId":"677842"}],["key4",{"taxcode":"AY","remtAmt":"74.0","propAmt":"","appAmt":"74.0","apcode":"","ticketTaxId":"677849"}],["key5",{"taxcode":"XY","remtAmt":"46.0","propAmt":"","appAmt":"46.0","apcode":"","ticketTaxId":"677850"}],["key6",{"taxcode":"XFHNL4.5","remtAmt":"0.0","propAmt":"","appAmt":"0.0","apcode":"","ticketTaxId":"677851"}],["key7",{"taxcode":"US","remtAmt":"293.0","propAmt":"","appAmt":"293.0","apcode":"","ticketTaxId":"677859"}],["key8",{"taxcode":"YC","remtAmt":"36.0","propAmt":"","appAmt":"36.0","apcode":"","ticketTaxId":"677860"}],["key9",{"taxcode":"XFLAS4.5","remtAmt":"0.0","propAmt":"","appAmt":"0.0","apcode":"","ticketTaxId":"677861"}]]

我尝试为每个参数创建一个数组,但失败了。

ticket_tax_dtls_id\n(\d+)

DB输出如下所示。

DB Output

1 个答案:

答案 0 :(得分:0)

以下正则表达式对我有用:

(\d{6})\s+\w+

使用屏幕截图中显示的设置捕获多个值。

截图参考:

正则表达式提取器:

enter image description here

查看结果树:

enter image description here

在问题中为给定的样本输出捕获了总共9个值。

我们可以稍后访问其中的每一个(tax_id是引用名称),如下所示:

first match : ${tax_id_1}
second match : ${tax_id_2}
continues..