简体   繁体   English

Apache Jmeter中的响应模式匹配

[英]Response pattern matching in apache jmeter

I am trying to do a response pattern match in Apache Jmeter. 我正在尝试在Apache Jmeter中进行响应模式匹配。

Here is a pattern that I have: 这是我的一种模式:

\{"exactMatchedResourceGroups" : \[ \{* "group2" * \} \],"parentMatchedResourceGroups" : \[ \]\}

I am trying to match this pattern with the below response: 我正在尝试将此模式与以下响应匹配:

{
 "exactMatchedResourceGroups" : [ {
 "id" : "b2f7947e-f502-4ad7-88b1-f7ac41bd44a7",
 "name" : "group2",
 "tags" : [ "" ]
} ],
"parentMatchedResourceGroups" : [ ]
}

I am getting this response from the server, but still the test is failing. 我从服务器收到此响应,但是测试仍然失败。 So, I am guessing its a problem with my regex. 因此,我猜我的正则表达式有问题。 I can't seem to figure out where the problem is. 我似乎无法弄清楚问题出在哪里。 Any help is appreciated. 任何帮助表示赞赏。

Try this one 试试这个

\{\s*"exactMatchedResourceGroups"\s*:\s*\[\s*\{.*?"group2".*?\s*\}\s*\]\s*,\s*"parentMatchedResourceGroups"\s*:\s*\[\s*\]\s*\}

you need to use option "s" dot all mode 您需要在所有模式下使用选项“ s”

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM