【发布时间】:2021-01-10 22:47:01
【问题描述】:
我正在尝试编写 Postman 测试并使用正则表达式验证个人身份证号。我已经验证了正则表达式:\b((([0-2]{1}[0-9]{1}|[3]{1}[0-1]{1})[0-9]{1}[0-9]{1}[0-9]{1}[0-9]{1}(.|\n|\t|)[0-9]{5})|[3]{1}[2]{1}[0-9]{4}(.|\n|\t|)[0-9]{5})\b
邮递员测试脚本:
var req = JSON.parse(pm.request.body.raw);
pm.expect(req.personnumber).to.match( \b((([0-2]{1}[0-9]{1}|[3]{1}[0-1]{1})[0-9]{1}[0-9]{1}[0-9]{1}[0-9]{1}(.|\n|\t|)[0-9]{5})|[3]{1}[2]{1}[0-9]{4}(.|\n|\t|)[0-9]{5}\b), "wwww" );
});
Postman 在尝试执行测试脚本时返回以下错误:
There was an error in evaluating the test script: SyntaxError: Invalid or unexpected token
【问题讨论】:
标签: javascript rest postman