正则表达式验证手机号和座机号

资源来源于网络

 #region 正则表达式验证电话号码
        public static bool CheckMobliePhoneV2(string phone)
        {
            //电信手机号码正则        
            string dianxin = @"^1[35789][01379]\d{8}$";
            Regex dReg = new Regex(dianxin);
            //联通手机号正则        
            string liantong = @"^1[34578][01256]\d{8}$";
            Regex tReg = new Regex(liantong);
            //移动手机号正则        
            string yidong = @"^(134[012345678]\d{7}|1[34578][012356789]\d{8})$";
            Regex yReg = new Regex(yidong);

            if (dReg.IsMatch(phone) || tReg.IsMatch(phone) || yReg.IsMatch(phone))
            {
                return true;
            }
            return false;
        }

        /// <summary>
        /// 座机号格式校验
        /// </summary>
        /// <param name="telephone"></param>
        /// <returns></returns>
        public bool checkTelephone(string telephone)
        {
            string zuoji = @"^((0\d{2,3})-)(\d{7,8})(-(\d{3,}))?$";  //比如:028-02866250077或0312-4295xxx的格式
            Regex gex = new Regex(zuoji);
            if (gex.IsMatch(telephone))
            {
                return true;
            }
            return false;
        }
        #endregion

猜你喜欢

转载自www.cnblogs.com/likui-bookHouse/p/9131823.html