邮箱的正则: var regemail = /^w{3,}@w+(.w+)+$/; if (!regemail.test(email)) { return; }
手机的正则 【不匹配】 var flag = !!phone.match(/^(0|86|17951)?(13[0-9]|15[0-9]|17[0-9]|18[0-9]|14[57])[0-9]{8}$/);
//邮编 var apostalreg = true; var regpostal = /^[1-9][0-9]{5}$/; if (!regpostal.test(postal)) { return; }
网址匹配 ①可以匹配完整的路径 var path= Regex.Match(str, @"[a-zA-z]+://[^s]*").Value 以下是在①的基础上完成的 ②可以匹配到.com Regex.Match(path, @"[(?<=http://)|(?<=https://)]+[w.]+[^/]").Value; Regex.Match(path, @"[(?<=http://)(?<=https://)]+[w.]+[^/]"); Regex.Match(lreg, @"[(?<=http://)(?<=https://)]+[w.]+[^/?]") ③域名 Regex.Match(log, @"((?<=http://)|(?<=https://))[w.]+[^/]");