当前位置: 首页 > 知识库问答 >
问题:

Regex提取[Jmeter]

墨高杰
2023-03-14
{"success":true,"data":[{"valId":null,"oclOclIdIndexType":null,"yearno":null,"docId":274253,"iconCls":null,"versionNo":1,"parentId":null,"id":"274253>1>>823132>1","nameId":"823132","name":"***PASTATAS 1 – Upės g. 11, Vilnius, Vilniaus m. sav.","menesiai":null,"ivedimas":null,"rowTypeIndex":1,"duomensTipas":null,"y":null,"m1":null,"m2":null,"m3":null,"m4":null,"m5":null,"m6":null,"m7":null,"m8":null,"m9":null,"m10":null,"m11":null,"m12":null,"yo":null,"m1o":null,"m2o":null,"m3o":null,"m4o":null,"m5o":null,"m6o":null,"m7o":null,"m8o":null,"m9o":null,"m10o":null,"m11o":null,"m12o":null,"avg":null,"editable":null,"isParent":true,"locked":false,"lockMsg":null,"icontype":"OBT_364","leaf":null,"dptname":null,"dpt_dpt_id":null,"is_all_dpt_data":null,"attId":null,"code":"TEST_PASTATAS_1","alokAggrType":"OTHER"},{"valId":null,"oclOclIdIndexType":null,"yearno":null,"docId":274753,"iconCls":null,"versionNo":1,"parentId":null,"id":"274753>1>>823163>2","nameId":"823163","name":"***PASTATAS 5 – Lvovo 45, Vilnius, Vilniaus m. sav.","menesiai":null,"ivedimas":null,"rowTypeIndex":1,"duomensTipas":null,"y":null,"m1":null,"m2":null,"m3":null,"m4":null,"m5":null,"m6":null,"m7":null,"m8":null,"m9":null,"m10":null,"m11":null,"m12":null,"yo":null,"m1o":null,"m2o":null,"m3o":null,"m4o":null,"m5o":null,"m6o":null,"m7o":null,"m8o":null,"m9o":null,"m10o":null,"m11o":null,"m12o":null,"avg":null,"editable":null,"isParent":true,"locked":false,"lockMsg":null,"icontype":"OBT_364","leaf":null,"dptname":null,"dpt_dpt_id":null,"is_all_dpt_data":null,"attId":null,"code":"TEST_PASTATAS_5","alokAggrType":"OTHER"},{"valId":null,"oclOclIdIndexType":null,"yearno":null,"docId":275104,"iconCls":null,"versionNo":1,"parentId":null,"id":"275104>1>>823180>3","nameId":"823180","name":"***PASTATAS 11 – Ukmergės 20, Vilnius, Vilniaus m. sav.","menesiai":null,"ivedimas":null,"rowTypeIndex":1,"duomensTipas":null,"y":null,"m1":null,"m2":null,"m3":null,"m4":null,"m5":null,"m6":null,"m7":null,"m8":null,"m9":null,"m10":null,"m11":null,"m12":null,"yo":null,"m1o":null,"m2o":null,"m3o":null,"m4o":null,"m5o":null,"m6o":null,"m7o":null,"m8o":null,"m9o":null,"m10o":null,"m11o":null,"m12o":null,"avg":null,"editable":null,"isParent":true,"locked":false,"lockMsg":null,"icontype":"OBT_364","leaf":null,"dptname":null,"dpt_dpt_id":null,"is_all_dpt_data":null,"attId":null,"code":"TEST_PASTATAS_11","alokAggrType":"OTHER"},{"valId":null,"oclOclIdIndexType":null,"yearno":null,"docId":275105,"iconCls":null,"versionNo":1,"parentId":null,"id":"275105>1>>823182>4","nameId":"823182","name":"Administracinis pastatas – Naugarduko 3, Vilnius, Vilniaus m. sav.","menesiai":null,"ivedimas":null,"rowTypeIndex":1,"duomensTipas":null,"y":null,"m1":null,"m2":null,"m3":null,"m4":null,"m5":null,"m6":null,"m7":null,"m8":null,"m9":null,"m10":null,"m11":null,"m12":null,"yo":null,"m1o":null,"m2o":null,"m3o":null,"m4o":null,"m5o":null,"m6o":null,"m7o":null,"m8o":null,"m9o":null,"m10o":null,"m11o":null,"m12o":null,"avg":null,"editable":null,"isParent":true,"locked":false,"lockMsg":null,"icontype":"OBT_364","leaf":null,"dptname":null,"dpt_dpt_id":null,"is_all_dpt_data":null,"attId":null,"code":"TEST_PASTATAS_12","alokAggrType":"OTHER"},{"valId":null,"oclOclIdIndexType":null,"yearno":null,"docId":275106,"iconCls":null,"versionNo":1,"parentId":null,"id":"275106>1>>823184>5","nameId":"823184","name":"***PASTATAS 13 – Grybų 35, Vilnius, Vilniaus m. sav.","menesiai":null,"ivedimas":null,"rowTypeIndex":1,"duomensTipas":null,"y":null,"m1":null,"m2":null,"m3":null,"m4":null,"m5":null,"m6":null,"m7":null,"m8":null,"m9":null,"m10":null,"m11":null,"m12":null,"yo":null,"m1o":null,"m2o":null,"m3o":null,"m4o":null,"m5o":null,"m6o":null,"m7o":null,"m8o":null,"m9o":null,"m10o":null,"m11o":null,"m12o":null,"avg":null,"editable":null,"isParent":true,"locked":false,"lockMsg":null,"icontype":"OBT_364","leaf":null,"dptname":null,"dpt_dpt_id":null,"is_all_dpt_data":null,"attId":null,"code":"TEST_PASTATAS_13","alokAggrType":"OTHER"},{"valId":null,"oclOclIdIndexType":null,"yearno":null,"docId":275630,"iconCls":null,"versionNo":1,"parentId":null,"id":"275630>1>>823760>6","nameId":"823760","name":"Mano pavadinimas 1 – Pilies 1, Vilniaus m.","menesiai":null,"ivedimas":null,"rowTypeIndex":1,"duomensTipas":null,"y":null,"m1":null,"m2":null,"m3":null,"m4":null,"m5":null,"m6":null,"m7":null,"m8":null,"m9":null,"m10":null,"m11":null,"m12":null,"yo":null,"m1o":null,"m2o":null,"m3o":null,"m4o":null,"m5o":null,"m6o":null,"m7o":null,"m8o":null,"m9o":null,"m10o":null,"m11o":null,"m12o":null,"avg":null,"editable":null,"isParent":true,"locked":false,"lockMsg":null,"icontype":"OBT_364","leaf":null,"dptname":null,"dpt_dpt_id":null,"is_all_dpt_data":null,"attId":null,"code":"OBJ_815895","alokAggrType":"OTHER"}],"messages":null}

美化的json响应:

{
"success": true,
"data": [{
    "valId": null,
    "oclOclIdIndexType": null,
    "yearno": null,
    "docId": 274253,
    "iconCls": null,
    "versionNo": 1,
    "parentId": null,
    "id": "274253>1>>823132>1",
    "nameId": "823132",
    "name": "***PASTATAS 1 – Upės g. 11, Vilnius, Vilniaus m. sav.",
    "menesiai": null,
    "ivedimas": null,
    "rowTypeIndex": 1,
    "duomensTipas": null,
    "y": null,
    "m1": null,
    "m2": null,
    "m3": null,
    "m4": null,
    "m5": null,
    "m6": null,
    "m7": null,
    "m8": null,
    "m9": null,
    "m10": null,
    "m11": null,
    "m12": null,
    "yo": null,
    "m1o": null,
    "m2o": null,
    "m3o": null,
    "m4o": null,
    "m5o": null,
    "m6o": null,
    "m7o": null,
    "m8o": null,
    "m9o": null,
    "m10o": null,
    "m11o": null,
    "m12o": null,
    "avg": null,
    "editable": null,
    "isParent": true,
    "locked": false,
    "lockMsg": null,
    "icontype": "OBT_364",
    "leaf": null,
    "dptname": null,
    "dpt_dpt_id": null,
    "is_all_dpt_data": null,
    "attId": null,
    "code": "TEST_PASTATAS_1",
    "alokAggrType": "OTHER"
},
{
    "valId": null,
    "oclOclIdIndexType": null,
    "yearno": null,
    "docId": 274753,
    "iconCls": null,
    "versionNo": 1,
    "parentId": null,
    "id": "274753>1>>823163>2",
    "nameId": "823163",
    "name": "***PASTATAS 5 – Lvovo 45, Vilnius, Vilniaus m. sav.",
    "menesiai": null,
    "ivedimas": null,
    "rowTypeIndex": 1,
    "duomensTipas": null,
    "y": null,
    "m1": null,
    "m2": null,
    "m3": null,
    "m4": null,
    "m5": null,
    "m6": null,
    "m7": null,
    "m8": null,
    "m9": null,
    "m10": null,
    "m11": null,
    "m12": null,
    "yo": null,
    "m1o": null,
    "m2o": null,
    "m3o": null,
    "m4o": null,
    "m5o": null,
    "m6o": null,
    "m7o": null,
    "m8o": null,
    "m9o": null,
    "m10o": null,
    "m11o": null,
    "m12o": null,
    "avg": null,
    "editable": null,
    "isParent": true,
    "locked": false,
    "lockMsg": null,
    "icontype": "OBT_364",
    "leaf": null,
    "dptname": null,
    "dpt_dpt_id": null,
    "is_all_dpt_data": null,
    "attId": null,
    "code": "TEST_PASTATAS_5",
    "alokAggrType": "OTHER"
},
{
    "valId": null,
    "oclOclIdIndexType": null,
    "yearno": null,
    "docId": 275104,
    "iconCls": null,
    "versionNo": 1,
    "parentId": null,
    "id": "275104>1>>823180>3",
    "nameId": "823180",
    "name": "***PASTATAS 11 – Ukmergės 20, Vilnius, Vilniaus m. sav.",
    "menesiai": null,
    "ivedimas": null,
    "rowTypeIndex": 1,
    "duomensTipas": null,
    "y": null,
    "m1": null,
    "m2": null,
    "m3": null,
    "m4": null,
    "m5": null,
    "m6": null,
    "m7": null,
    "m8": null,
    "m9": null,
    "m10": null,
    "m11": null,
    "m12": null,
    "yo": null,
    "m1o": null,
    "m2o": null,
    "m3o": null,
    "m4o": null,
    "m5o": null,
    "m6o": null,
    "m7o": null,
    "m8o": null,
    "m9o": null,
    "m10o": null,
    "m11o": null,
    "m12o": null,
    "avg": null,
    "editable": null,
    "isParent": true,
    "locked": false,
    "lockMsg": null,
    "icontype": "OBT_364",
    "leaf": null,
    "dptname": null,
    "dpt_dpt_id": null,
    "is_all_dpt_data": null,
    "attId": null,
    "code": "TEST_PASTATAS_11",
    "alokAggrType": "OTHER"
},
{
    "valId": null,
    "oclOclIdIndexType": null,
    "yearno": null,
    "docId": 275105,
    "iconCls": null,
    "versionNo": 1,
    "parentId": null,
    "id": "275105>1>>823182>4",
    "nameId": "823182",
    "name": "Administracinis pastatas – Naugarduko 3, Vilnius, Vilniaus m. sav.",
    "menesiai": null,
    "ivedimas": null,
    "rowTypeIndex": 1,
    "duomensTipas": null,
    "y": null,
    "m1": null,
    "m2": null,
    "m3": null,
    "m4": null,
    "m5": null,
    "m6": null,
    "m7": null,
    "m8": null,
    "m9": null,
    "m10": null,
    "m11": null,
    "m12": null,
    "yo": null,
    "m1o": null,
    "m2o": null,
    "m3o": null,
    "m4o": null,
    "m5o": null,
    "m6o": null,
    "m7o": null,
    "m8o": null,
    "m9o": null,
    "m10o": null,
    "m11o": null,
    "m12o": null,
    "avg": null,
    "editable": null,
    "isParent": true,
    "locked": false,
    "lockMsg": null,
    "icontype": "OBT_364",
    "leaf": null,
    "dptname": null,
    "dpt_dpt_id": null,
    "is_all_dpt_data": null,
    "attId": null,
    "code": "TEST_PASTATAS_12",
    "alokAggrType": "OTHER"
},
{
    "valId": null,
    "oclOclIdIndexType": null,
    "yearno": null,
    "docId": 275106,
    "iconCls": null,
    "versionNo": 1,
    "parentId": null,
    "id": "275106>1>>823184>5",
    "nameId": "823184",
    "name": "***PASTATAS 13 – Grybų 35, Vilnius, Vilniaus m. sav.",
    "menesiai": null,
    "ivedimas": null,
    "rowTypeIndex": 1,
    "duomensTipas": null,
    "y": null,
    "m1": null,
    "m2": null,
    "m3": null,
    "m4": null,
    "m5": null,
    "m6": null,
    "m7": null,
    "m8": null,
    "m9": null,
    "m10": null,
    "m11": null,
    "m12": null,
    "yo": null,
    "m1o": null,
    "m2o": null,
    "m3o": null,
    "m4o": null,
    "m5o": null,
    "m6o": null,
    "m7o": null,
    "m8o": null,
    "m9o": null,
    "m10o": null,
    "m11o": null,
    "m12o": null,
    "avg": null,
    "editable": null,
    "isParent": true,
    "locked": false,
    "lockMsg": null,
    "icontype": "OBT_364",
    "leaf": null,
    "dptname": null,
    "dpt_dpt_id": null,
    "is_all_dpt_data": null,
    "attId": null,
    "code": "TEST_PASTATAS_13",
    "alokAggrType": "OTHER"
},
{
    "valId": null,
    "oclOclIdIndexType": null,
    "yearno": null,
    "docId": 275630,
    "iconCls": null,
    "versionNo": 1,
    "parentId": null,
    "id": "275630>1>>823760>6",
    "nameId": "823760",
    "name": "Mano pavadinimas 1 – Pilies 1, Vilniaus m.",
    "menesiai": null,
    "ivedimas": null,
    "rowTypeIndex": 1,
    "duomensTipas": null,
    "y": null,
    "m1": null,
    "m2": null,
    "m3": null,
    "m4": null,
    "m5": null,
    "m6": null,
    "m7": null,
    "m8": null,
    "m9": null,
    "m10": null,
    "m11": null,
    "m12": null,
    "yo": null,
    "m1o": null,
    "m2o": null,
    "m3o": null,
    "m4o": null,
    "m5o": null,
    "m6o": null,
    "m7o": null,
    "m8o": null,
    "m9o": null,
    "m10o": null,
    "m11o": null,
    "m12o": null,
    "avg": null,
    "editable": null,
    "isParent": true,
    "locked": false,
    "lockMsg": null,
    "icontype": "OBT_364",
    "leaf": null,
    "dptname": null,
    "dpt_dpt_id": null,
    "is_all_dpt_data": null,
    "attId": null,
    "code": "OBJ_815895",
    "alokAggrType": "OTHER"
}],
"messages": null

}

我需要提取docId、id、nameId,因为我总是知道代码。

"valId":null,"oclOclIdIndexType":null,"yearno":null,"docId":(.+?),"iconCls":null,"versionNo":1,"parentId":null,"id":"(.+?)","nameId":"(.+?)","name":".+?","menesiai":null,"ivedimas":null,"rowTypeIndex":1,"duomensTipas":null,"y":null,"m1":null,"m2":null,"m3":null,"m4":null,"m5":null,"m6":null,"m7":null,"m8":null,"m9":null,"m10":null,"m11":null,"m12":null,"yo":null,"m1o":null,"m2o":null,"m3o":null,"m4o":null,"m5o":null,"m6o":null,"m7o":null,"m8o":null,"m9o":null,"m10o":null,"m11o":null,"m12o":null,"avg":null,"editable":null,"isParent":true,"locked":false,"lockMsg":null,"icontype":"OBT_364","leaf":null,"dptname":null,"dpt_dpt_id":null,"is_all_dpt_data":null,"attId":null,"code":"OBJ_815895"
**Reference Name** : code
**Regular Expression** : "code":"(.+?)"
**Template** : $1$
**Match No.** : -1
**Reference Name** : docId
**Regular Expression** : "docId":(\d+)
**Template** : $1$
**Match No.** : -1

添加了groovy脚本来设置参数

for(int i = 1; i<vars.get("code_matchNr");i++){
    if(vars.get("code_"+i) == vars.get("objectId")){
        vars.put("docId",vars.get("docId_"+i));
        vars.put("id",vars.get("id_"+i));
        vars.put("nameId",vars.get("nameId_"+i));
    }
}

共有1个答案

林德惠
2023-03-14

添加正则表达式提取器,一个示例:

  • referenceName:docid
  • 正则表达式:“docid”:“(.*?)”
  • 模板:$1$
  • 匹配号:-1

因为阴性匹配号:

    null
 类似资料:
  • 问题内容: 我需要在python中编写一个正则表达式以从Tweets中提取提及。 我的尝试: 对于@mickey之类的任何提及,它都可以正常工作,但是,在带有@mickey_mouse之类的下划线的提及中,它仅提取@mickey。 如何修改正则表达式以使其在两种情况下均能正常工作? 谢谢 问题答案: 在下一组添加下划线,如下所示: Regex101演示 另外,Twitter Handle规则 允许

  • 问题内容: 我正在尝试提取其中的任何数据。 例如,从此字符串提取的数据应为。 这是实际的代码: 但这行不通,知道吗? 问题答案: 您需要转义,并在正则表达式中。 Golang示范 在正则表达式中 您也可以使用

  • 此regex:使用多个组匹配表达式。regex的要点是它捕获两个成对的模式,其中regex的第一部分必须跟在regex的第二部分后面。 如何提取这两个组中的每一个? 这里的关键是regex匹配两次,每次包含2个组。我希望每个匹配都有一个它自己的列表,这个列表包含2个元素,每个组一个。

  • 我试图从Splunk payload_printable字段中提取一个域(源是Suricata日志),发现这个正则表达式在大多数情况下都能正常工作: 正则表达式为: 我不知道该怎么做。谢谢你的帮助。

  • 使用Java11,我想知道如何使用流应用编程接口将所有组匹配提取到一行程序中的字符串列表。 给定此regexp和字符串: 我知道如何在多行中获得结果: 这将打印3个不同数字字符串的预期列表:[123,8,90] 我试图在一条航线上实现同样的目标: 这将打印意外的:[123-8-90] 如何在流中使用MatchResult::group(int)方法?

  • 本文向大家介绍Python Regex从字符串中提取最大数值,包括了Python Regex从字符串中提取最大数值的使用技巧和注意事项,需要的朋友参考一下 使用正则表达式从字符串中提取最大数值的最简单方法是- 使用regex模块从字符串中提取所有数字 从这些数字中找到最大值 例如,对于输入字符串- 这个城市有121005人,邻近城市有1587469人,而遥远城市有18775994人。 我们应该得到