Example #1
0
        /// <summary>
        /// 判断输入的字符串是否是合法的IPV6 地址
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public static bool IsIPV6(string input)
        {
            string pattern = "";
            string temp    = input;

            string[] strs = temp.Split(':');
            if (strs.Length > 8)
            {
                return(false);
            }
            int count = RegexUtil.GetStringCount(input, "::");

            if (count > 1)
            {
                return(false);
            }
            else if (count == 0)
            {
                pattern = @"^([\da-f]{1,4}:){7}[\da-f]{1,4}$";
                return(IsMatch(pattern, input));
            }
            else
            {
                pattern = @"^([\da-f]{1,4}:){0,5}::([\da-f]{1,4}:){0,5}[\da-f]{1,4}$";
                return(IsMatch(pattern, input));
            }
        }
Example #2
0
 /// <summary>
 /// 静态实例化单体模式
 /// 保证应用程序操作某一全局对象,让其保持一致而产生的对象
 /// </summary>
 /// <returns></returns>
 public static RegexUtil GetInstance()
 {
     if (RegexUtil.instance == null)
     {
         RegexUtil.instance = new RegexUtil();
     }
     return(RegexUtil.instance);
 }