zoukankan      html  css  js  c++  java
  • 一个非常好用的日期正则表达式

    一个非常好用的日期正则表达式。
    (可检验以下格式的日期(2008-01-01/2008-1-1/2008-01-1/2008-1-01))
     
    string format = @"^((((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]|1\d|2[0-8]))|(((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))-0?2-29))$";
                Regex reg = new Regex(format);
                Match m = reg.Match(date);
                if (!m.Success)
                {
                    MessageBox.Show("日期格式不对!");
                    return false;
                }
  • 相关阅读:
    CF1416D Graph and Queries
    Wordpress建站系统相关
    微观经济学
    Preface
    Thread pool in chromium
    [fllutter engine] 并发消息队列
    bugku misc
    python 3.1学习
    HTML&CSS
    DOM技术点
  • 原文地址:https://www.cnblogs.com/chhuic/p/1537623.html
Copyright © 2011-2022 走看看