Example #1
0
 /// <summary>
 /// 是否为固话号
 /// </summary>
 public static bool IsPhone(string s)
 {
     return(IsPlumpString(s) && RegexHelper.IsMatch(s, @"^(\d{3,4}-?)?\d{7,8}$"));
 }
Example #2
0
 /// <summary>
 /// 是否是域名
 /// </summary>
 /// <param name="s"></param>
 /// <returns></returns>
 public static bool IsDomain(string s)
 {
     return(IsPlumpString(s) && RegexHelper.IsMatch(s, @"^[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+$"));
 }
Example #3
0
 /// <summary>
 /// 判断是不是url
 /// </summary>
 /// <param name="s"></param>
 /// <returns></returns>
 public static bool IsURL(string s)
 {
     return(IsPlumpString(s) && RegexHelper.IsMatch(s, @"[a-zA-z]+://[^s]*"));
 }
Example #4
0
 /// <summary>
 /// 是手机号
 /// </summary>
 /// <param name="s"></param>
 /// <returns></returns>
 public static bool IsMobilePhone(string s)
 {
     return(IsPlumpString(s) && RegexHelper.IsMatch(s, @"^(13[0-9]|14[5|7]|15[0|1|2|3|5|6|7|8|9]|18[0|1|2|3|5|6|7|8|9])\d{8}$"));
 }
Example #5
0
 /// <summary>
 /// 是否是数字
 /// </summary>
 /// <param name="s"></param>
 /// <returns></returns>
 public static bool IsNumber(string s)
 {
     return(IsPlumpString(s) && RegexHelper.IsMatch(s, @"^[0-9]*$"));
 }
Example #6
0
 /// <summary>
 /// 判断是否是邮件地址,来自nop的方法
 /// </summary>
 /// <param name="s"></param>
 /// <returns></returns>
 public static bool IsEmail(string s)
 {
     return(IsPlumpString(s) && RegexHelper.IsMatch(s, @"^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$"));
 }
Example #7
0
 /// <summary>
 /// 是否是时间
 /// </summary>
 /// <param name="s"></param>
 /// <returns></returns>
 public static bool IsTime(string s)
 {
     return(IsPlumpString(s) && RegexHelper.IsMatch(s, @"^(([0-1]?[0-9])|([2][0-3])):([0-5]?[0-9])(:([0-5]?[0-9]))?$"));
 }
Example #8
0
 /// <summary>
 /// 数字或者字母
 /// </summary>
 /// <param name="s"></param>
 /// <returns></returns>
 public static bool IsNUMBER_OR_CHAR(string s)
 {
     return(IsPlumpString(s) && RegexHelper.IsMatch(s, @"^[A-Za-z0-9]{4,40}$"));
 }
Example #9
0
 public static bool IsIPv4(string s) =>
 IsPlumpString(s) && RegexHelper.IsMatch(s, @"^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$");
Example #10
0
 public static bool IsIPv6(string s) =>
 IsPlumpString(s) && RegexHelper.IsMatch(s, @"/^((?=.*::)(?!.*::.+::)(::)?([\dA-F]{1,4}:(:|\b)|){5}|([\dA-F]{1,4}:){6})((([\dA-F]{1,4}((?!\3)::|:\b|$))|(?!\2\3)){2}|(((2[0-4]|1\d|[1-9])?\d|25[0-5])\.?\b){4})$/i");
Example #11
0
 /// <summary>
 /// 是否是IP
 /// </summary>
 public static bool IsIP(string s) =>
 IsPlumpString(s) && RegexHelper.IsMatch(s, @"\d+\.\d+\.\d+\.\d+");
Example #12
0
 /// <summary>
 /// 是否是身份证号
 /// </summary>
 /// <param name="s"></param>
 /// <returns></returns>
 public static bool IsIDCardNo(string s)
 {
     return(IsPlumpString(s) && RegexHelper.IsMatch(s, @"^(^\d{15}$|^\d{18}$|^\d{17}(\d|X|x))$"));
 }
Example #13
0
 /// <summary>
 /// 是否是中文
 /// </summary>
 /// <param name="s"></param>
 /// <returns></returns>
 public static bool IsChinese(string s)
 {
     return(IsPlumpString(s) && RegexHelper.IsMatch(s, @"^[\u4e00-\u9fa5]{0,}$"));
 }
Example #14
0
 /// <summary>
 /// 判断是否是邮件地址,来自nop的方法
 /// </summary>
 /// <param name="s"></param>
 /// <returns></returns>
 public static bool IsMailAddress(string s)
 {
     return(IsNotEmpty(s) && RegexHelper.IsMatch(s, @"^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$"));
 }
Example #15
0
 /// <summary>
 /// 是否是IP
 /// </summary>
 public static bool IsIP(string s) =>
 IsNotEmpty(s) && RegexHelper.IsMatch(s, @"\d+\.\d+\.\d+\.\d+");