[英]jmeter Regular Expression Extractor to extract string from multi string
I have multiple string of grp and name in the response message. 我在响应消息中有多个字符串grp和名称。 I want to extract the grp based on unique name ,"grp":(.+?),"name":"UNIQUE_STRING"
我想根据唯一名称“ grp”:(。+?),“ name”:“ UNIQUE_STRING”提取grp
Regular Expression Extractor Reference Name: group_name Regular
正则表达式提取器参考名称:group_name正则
Expression: "grp":(.+?),"name":"UNIQUE_STRING" Template : $1$ Match no: 1
表达式:“ grp”:(。+?),“ name”:“ UNIQUE_STRING”模板:$ 1 $匹配号:1
I want to extract the preceding value based on the unique name but not able to find.. Please help 我想根据唯一名称提取先前的值,但无法找到..请帮助
You can find string until the first comma: 您可以找到字符串,直到第一个逗号为止:
Regular Expression: grp":([^,]+),"name":"UNIQUE_STRING
If you want to remove " in grp value (find 123 for grp":"123") use: 如果要删除grp值中的“(grp的查找值为123”:“ 123”),请使用:
Regular Expression: grp":"([^,]+)","name":"UNIQUE_STRING
Your response is utterly like to be a JSON , if this is the case I believe it will be much easier to use JSON Extractor (available since JMeter 3.0) 您的回答完全像是JSON ,如果是这种情况,我相信使用JSON Extractor会容易得多 (自JMeter 3.0起可用)
If your response data looks something like: 如果您的响应数据如下所示:
[
{
"grp": "foo",
"name": "UNIQUE_STRING"
},
{
"grp": "bar",
"name": "ANOTHER_STRING"
}
]
You should be able to extract this foo
value using a simple Json Path query like: $..[?(@.name == 'UNIQUE_STRING')].grp
您应该能够使用简单的Json Path查询来提取此
foo
值,例如: $..[?(@.name == 'UNIQUE_STRING')].grp
Demo: 演示:
More information: JMeter's JSON Path Extractor Plugin - Advanced Usage Scenarios 详细信息: JMeter的JSON路径提取器插件-高级用法方案
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.