首页 > 代码库 > 判断是否十六进制格式字符串

判断是否十六进制格式字符串


        /// 判断是否十六进制格式字符串
    
        public bool IsHexadecimal(string str)
        {
            const string PATTERN = @"[A-Fa-f0-9]+$";
            return System.Text.RegularExpressions.Regex.IsMatch(str, PATTERN);
        }

   
        /// 判断是否八进制格式字符串
    
        public bool IsOctal(string str)
        {
            const string PATTERN = @"[0-7]+$";
            return System.Text.RegularExpressions.Regex.IsMatch(str, PATTERN);
        }

      
        /// 判断是否二进制格式字符串
      
        public bool IsBinary(string str)
        {
            const string PATTERN = @"[0-1]+$";
            return System.Text.RegularExpressions.Regex.IsMatch(str, PATTERN);
        }

   
        /// 判断是否十进制格式字符串
     
        public bool IsDecimal(string str)
        {
            const string PATTERN = @"[0-9]+$";
            return System.Text.RegularExpressions.Regex.IsMatch(str, PATTERN);
        }

判断是否十六进制格式字符串