标签:str pre res 正则 pat exp json 动态 console
var code = 123222;
var pattern = ‘{"code":‘ + code + ‘,"regin":"[\u4e00-\u9fa5]+"}‘;
var reg = new RegExp(pattern);
var str = ‘{"code":123222,"regin":"汉字"}‘;
var result = reg.exec(str)
console.log(JSON.parse(result[0]))
标签:str pre res 正则 pat exp json 动态 console
原文地址:https://www.cnblogs.com/Merrys/p/9623176.html