首页 > 代码库 > 常用正则表达式集锦

常用正则表达式集锦

1. IsMatch()

 //IP正则表达式        private static Regex _ipregex = new Regex(@"^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$");  /// <summary>        /// 是否为IP        /// </summary>        public static bool IsIP(string s)        {            return _ipregex.IsMatch(s);        }
View Code

2. 

常用正则表达式集锦