一个关于 电话号码 的正则表达式

//验证是否为电话号码
  bool IsValidTel(string strIn)
  {
   //   return Regex.IsMatch(strIn,@"(\d+-)?(\d{4}-?\d{7}|\d{3}-?\d{8}|^\d{7,8})(-\d+)?");
   return Regex.IsMatch(strIn,@"(^[0-9]{3,4}\-[0-9]{7,8}$)|(^[0-9]{7,8}$)|(^\([0-9]{3,4}\)[0-9]{7,8}$)|(^0{0,1}13[0-9]{9}$)|(^0{0,1}15[0-9]{9}$)|((\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})$)|((\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})$)");
   //  return Regex.IsMatch(strIn,@"[\d-]{8,}");
   //  return Regex.IsMatch(strIn,@"((\d{11})|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1}))$)");
  }

其中:(\d{11})|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1}))$)

 

支持,

11位手机号码

3-4位区号,7-8位直播号码,1-4位分机号

你可能感兴趣的:(正则表达式)