2016-09-05 35 views
-2

我需要使用正则表达式来获取ID的值。Jmeter正则表达式来从2行中获取值

“年”: “2020”,(?(* \ n){2})

使用此我得到 “身份证”: “2221111111”, 我只是想编号为id。 我如何得到这个。谢谢

这是我想从中获取id的文本。编号为2号线

“年”: “2020”, “ID”: “2221111111”,

回答

0

你需要的东西是这样的:

var test = { 
    "yr" : "2020", 
    "id" : "2221111111", 
}; 

var str = JSON.stringify(test); 

var matches = str.match(/"id"."\d+"/g); 
var id = matches[0].replace(/\D/g,''); 

console.log(id); // 2221111111 

Snippet is here

+0

我必须在json代码上应用正则表达式。我该如何改进这个“年”:“2020”,((。*?\ n){2})来获取id的值。谢谢 – Rock

+0

我向你展示了解决方案,通过stringify函数将JSON转换为字符串并应用我的正则表达式 – booboos

0
"yr" : "2020", "id" : "(\d+)", 

这可能会帮助你提取id的值,即2221111111,如果你的“id” :“2221111111”,在下一行然后

"yr" : "2020",\n"id" : "(\d+)",