正则表达式-身份证号

const idc = "12345678912345678X";
const reg = /(^\d{15}$)|(^\d{17}(\d|X)$)/g;  //15位数字 18位数字 或 17位数字+X
const a = reg.test(idc); //true
const b = idc.match(reg);
console.log("=======", a, b);
posted @ 2022-07-27 16:51  人恒过  阅读(126)  评论(0)    收藏  举报