记录:手机邮箱格式验证

        /// 
        /// 验证手机号固定电话
        /// 
        /// 
        /// 
        public static bool CheckMobliePhone(string phone)
        {
            //电信手机号码正则        
            string dianxin = @"^1[3578][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][0123456789]\d{8})$";
            Regex yReg = new Regex(yidong);

            if (dReg.IsMatch(phone) || tReg.IsMatch(phone) || yReg.IsMatch(phone))
            {
                return true;
            }
            return false;
        }
        /// 
        /// 验证邮箱格式
        /// 
        /// 
        /// 
        public static bool CheckEmail(string email)
        {
            //邮箱正则        
            string dianxin = @"^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$";
            Regex dReg = new Regex(dianxin);
            if (dReg.IsMatch(email))
            {
                return true;
            }
            return false;
        }

 

你可能感兴趣的:(c#,c#,验证,手机号,邮箱,正则)