public static class RegxCheck { /// <summary> /// 正则表达式验证是否为手机号 /// </summary> /// <param name="telNum">需要验证的手机号</param> /// <returns></returns> public static bool CheckTelNum(string telNum) { //电信手机号码正则 string telecom = @"^1[3578][01379]\d{8}$"; Regex telecomReg = new Regex(telecom); //联通手机号正则 string unicom = @"^1[34578][01256]\d{8}$"; Regex unicomReg = new Regex(unicom); //移动手机号正则 string cmcc = @"^(134[012345678]\d{7}|1[34578][012356789]\d{8})$"; Regex cmccReg = new Regex(cmcc); return telecomReg.IsMatch(telNum) || unicomReg.IsMatch(telNum) || cmccReg.IsMatch(telNum); } }
时间: 2024-10-19 21:27:22