1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
public static bool CheckPhoneNumber(string strPhoneNumber) { try { if (strPhoneNumber.Length == 14) { strPhoneNumber.Replace("+86", string.Empty); } string strRegexChinaTelecom = @"^1[3578][01379]\d{8}$"; Regex regexChinaTelecom = new Regex(strRegexChinaTelecom); string strRegexChinaMobile = @"^(134[012345678]\d{7}|1[34578][012356789]\d{8})$"; Regex regexChinaMobile = new Regex(strRegexChinaMobile); string strRegexChinaUnicom = @"^1[34578][01256]\d{8}$"; Regex regexChinaUnicom = new Regex(strRegexChinaUnicom); if (regexChinaTelecom.IsMatch(strPhoneNumber) || regexChinaMobile.IsMatch(strPhoneNumber) || regexChinaUnicom.IsMatch(strPhoneNumber)) { return true; } else { return false; } } catch (Exception ex) { return false; } }
|