JMeter:如何使用正则表达式提取重复字段的值? [英] JMeter: How to use Regular Expression to extract the value of a duplicate field?
本文介绍了JMeter:如何使用正则表达式提取重复字段的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下响应正文JSON:
I have the following Response Body JSON:
{
"address": [
{
"id": "1234"
}
],
"id": "d1a4f010-48d9-434b-9b3a-2d2b12f5e38c"
}
我正在尝试提取 second "id"字段的值,即
I am trying to extract the value of the the second "id" field, i.e.
"id": "d1a4f010-48d9-434b-9b3a-2d2b12f5e38c"
我在JMeter中使用以下正则表达式: 正则表达式:"id":(.+?)"
I use this Regular Expression in JMeter: Regular Expression: "id":"(.+?)"
运行测试时,它将返回"1234"而不是GUID.如何更改我的正则表达式,使其返回GUID?
When I run my test, it returns "1234" instead of the guid. How can I change my Regular Expression so that it returns the guid?
推荐答案
您可以使用惰性正则表达式直接查找guid,而不用查找"id"
You can use a lazy regex to find the guid directly instead of finding "id"
类似这样的内容:([0-9a-z-]{36}).*?
如果不确定如何创建正则表达式,只需使用在线正则表达式制造商即可.
If you are not sure how to create the regex, just use an online regex maker.
这篇关于JMeter:如何使用正则表达式提取重复字段的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文