• 正则表达式大全——持续更新中。。。


    public static class RegexExtensions
        {
            /// <summary>
            /// 是否为日期型字符串
            /// </summary>
            /// <param name="StrSource">日期字符串(2008-05-08)</param>
            /// <returns></returns>
            public static bool IsDate(this string StrSource)
            {
                return Regex.IsMatch(StrSource, @"^((((1[6-9]|[2-9]d)d{2})-(0?[13578]|1[02])-(0?[1-9]|[12]d|3[01]))|(((1[6-9]|[2-9]d)d{2})-(0?[13456789]|1[012])-(0?[1-9]|[12]d|30))|(((1[6-9]|[2-9]d)d{2})-0?2-(0?[1-9]|1d|2[0-9]))|(((1[6-9]|[2-9]d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))-0?2-29-))$");
            }
    
            /// <summary>
            /// 是否为时间型字符串
            /// </summary>
            /// <param name="StrSource">时间字符串(15:00:00)</param>
            /// <returns></returns>
            public static bool IsTime(this string StrSource)
            {
                return Regex.IsMatch(StrSource, @"^((20|21|22|23|[0-1]?d):[0-5]?d:[0-5]?d)$");
            }
    
            /// <summary>
            /// 是否为日期+时间型字符串
            /// </summary>
            /// <param name="StrSource"></param>
            /// <returns></returns>
            public static bool IsDateTime(this string StrSource)
            {
                return Regex.IsMatch(StrSource, @"^(((((1[6-9]|[2-9]d)d{2})-(0?[13578]|1[02])-(0?[1-9]|[12]d|3[01]))|(((1[6-9]|[2-9]d)d{2})-(0?[13456789]|1[012])-(0?[1-9]|[12]d|30))|(((1[6-9]|[2-9]d)d{2})-0?2-(0?[1-9]|1d|2[0-8]))|(((1[6-9]|[2-9]d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))-0?2-29-)) (20|21|22|23|[0-1]?d):[0-5]?d:[0-5]?d)$ ");
            }
    
            //是否是整数
            public static bool IsInt(this string StrSource)
            {
                return Regex.IsMatch(StrSource, @"^[0-9]*$");
            }
        }
  • 相关阅读:
    linux --- 3 vim 网络 用户 权限 软连接 压缩 定时任务 yum源
    linux --- 2.常用命令 , python3, django安装
    linux --- 1.初始linux
    admin ---11.admin , 展示列表 和 分页
    并发 ---- 6. IO 多路复用
    django基础 -- 10.form , ModelForm ,modelformset
    django基础 -- 9.中间件
    flask基础
    MySQL-数据库增删改查
    面试题目二
  • 原文地址:https://www.cnblogs.com/guyun/p/10344929.html
Copyright © 2020-2023  润新知