根据JMeter中使用正则表达式给出的条件选择匹配

时间:2014-09-27 17:55:44

标签: regex jmeter

如果我的回复如下:

{"id":"140","rsd":null,"col":"green","cc":"B5307F","pn":"KENWAY TYRES RENEWAL 2014","loc":"ABD - LR / L3 / L3","isf":"1","isl":"0","tq":"15","pi":null,"st":"1","dsid":"15","cid":"2120","spl":null,"wid":"WI/3ivdfzhg","inv":null,"pdid":"1103","di":"0","pl":"0"}{"id":"141","rsd":null,"col":"green","cc":"B5307F","pn":"KENWAY TYRES RENEWAL 2014","loc":"ABD - LR / L3 / L3","isf":"1","isl":"0","tq":"15","pi":null,"st":"7","dsid":"15","cid":"2120","spl":null,"wid":"WI/3ivdfzhg","inv":null,"pdid":"1103","di":"0","pl":"0"}

如果我需要check st=7inv=null并且仅提取141而不是140.

我该怎么办?提前谢谢。

2 个答案:

答案 0 :(得分:1)

(?=.*?inv":null)(?=(?:(?!st).)*?st":"7)"id":"(\d+)

试试这个。看看演示。

http://regex101.com/r/lS5tT3/68

答案 1 :(得分:0)

您可以直接使用Listener>查看结果树而不是使用其他网站来检查JMETER的正则表达式结果,在下拉列表中,您可以选择Regex测试器代替Text,以便获得准确的结果。我附加图像 enter image description here