JS 正则匹配手机号码、邮箱等

匹配手机号码

var pattern = /(13\d|14[579]|15[^4\D]|17[^49\D]|18\d)\d{8}/g;
var str = 'xxx';
console.log(pattern.test(str));

匹配邮箱

var pattern = /\w[-\w.+]*@([A-Za-z0-9][-A-Za-z0-9]+\.)+[A-Za-z]{2,14}/g;
var str = 'xxx';
console.log(pattern.test(str));

匹配身份证

var pattern = /\d{17}[0-9Xx]|\d{15}/g;
var str = 'xxx';
console.log(pattern.test(str));

你可能感兴趣的:(JS 正则匹配手机号码、邮箱等)