正则表达式 日期

Title:   Pattern   Title   [Details]   [Test]      
  Expression:   ^(3[0-1]|2[0-9]|1[0-9]|0[1-9])["s{1}|"/|-](Jan|JAN|Feb|FEB|Mar|MAR|Apr|APR|May|MAY|Jun|JUN|Jul|JUL|Aug|AUG|Sep|SEP|Oct|OCT|Nov|NOV|Dec|DEC)["s{1}|"/|-]"d{4}$      
       
  Description:   More   flexible   date   validator.   Allows   either   spaces,   /   or   -   as   dividers,   also   allows   for   fully   uppercase   months,   year   as   4   digit.    
  Matches:   01   JAN   2003|||31/Dec/2002|||20-Apr-2003    
  Non-Matches:   32   Jan   2003|||00   Dec   2003|||10   dec   2003    
       
  Author:   Ian   Wallace   Rating:   Not   yet   rated.      
     
  Title:   MMM   dd,   yyyy   Date   [Details]   [Test]      
  Expression:   ^(?:(((Jan(uary)?|Ma(r(ch)?|y)|Jul(y)?|Aug(ust)?|Oct(ober)?|Dec(ember)?)"   31)|((Jan(uary)?|Ma(r(ch)?|y)|Apr(il)?|Ju((ly?)|(ne?))|Aug(ust)?|Oct(ober)?|(Sept|Nov|Dec)(ember)?)"   (0?[1-9]|([12]"d)|30))|(Feb(ruary)?"   (0?[1-9]|1"d|2[0-8]|(29(?=,"   ((1[6-9]|[2-9]"d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)))))))","   ((1[6-9]|[2-9]"d)"d{2}))      
       
  Description:   This   RE   validate   Dates   in   the   MMM   dd,   yyyy   format   from   Jan   1,   1600   to   Dec   31,   9999.   The   format   is   as   follows:   The   name   or   3   letter   abbreivation,   without   a   period,   of   the   month,   then   a   space   then   the   day   value   then   a   comma   then   a   space   finally   the   year.   The   correct   number   of   day   are   validated   for   each   month   include   leap   years.   The   name   of   month   is   case   sensitive.    
  Matches:   Jan   1,   2003|||February   29,   2004|||November   02,   3202    
  Non-Matches:   Feb   29,   2003|||Apr   31,   1978|||jan   33,3333    
       
  Author:   Michael   Ash   Rating:        
     
  Title:   dd   MMM   yyyy   Date   [Details]   [Test]      
  Expression:   ^((31(?!"   (Feb(ruary)?|Apr(il)?|June?|(Sep(?="b|t)t?|Nov)(ember)?)))|((30|29)(?!"   Feb(ruary)?))|(29(?="   Feb(ruary)?"   (((1[6-9]|[2-9]"d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)))))|(0?[1-9])|1"d|2[0-8])"   (Jan(uary)?|Feb(ruary)?|Ma(r(ch)?|y)|Apr(il)?|Ju((ly?)|(ne?))|Aug(ust)?|Oct(ober)?|(Sep(?="b|t)t?|Nov|Dec)(ember)?)"   ((1[6-9]|[2-9]"d)"d{2})$      
       
  Description:   This   RE   validates   dates   in   the   dd   MMM   yyyy   format.   Spaces   separate   the   values.    
  Matches:   31   January   2003|||29   March   2004|||29   Feb   2008    
  Non-Matches:   Jan   1   2003|||31   Sept   2003|||29   February   2003    
       
  Author:   Michael   Ash   Rating:        
     
  Title:   Months   [Details]   [Test]      
  Expression:   ^(?:J(anuary|u(ne|ly))|February|Ma(rch|y)|A(pril|ugust)|(((Sept|Nov|Dec)em)|Octo)ber)$      
       
  Description:   This   RE   validate   the   full   name   of   the   months.    
  Matches:   January|||May|||October    
  Non-Matches:   Jan|||Septem|||Octo    
       
  Author:   Michael   Ash   Rating:        
     
  Title:   Pattern   Title   [Details]   [Test]      
  Expression:   ^(?<From>(JANUARY|FEBRUARY|MARCH|APRIL|MAY|JUNE|JULY|AUGUST|SEPTEMBER|OCTOBER|NOVEMBER|DECEMBER|[   ]|,|/|[0-9])+)(-|–|:|TO)?(?<To>(JANUARY|FEBRUARY|MARCH|APRIL|MAY|JUNE|JULY|AUGUST|SEPTEMBER|OCTOBER|NOVEMBER|DECEMBER|[   ]|,|/|[0-9]|PRESENT)+)+(:)*      
       
  Description:   This   regular   expression   will   match   date   given   in   any   format   expcept   (mmm).   Its   speciality   is   that   it   divides   dates   into   <from>   part   and   <to>   part.   Use   Groups   to   access   these   parts.   e.g.   JANUARY   1998   TO   JUNE   2000   <From>="JANUARY   1998"   <to>="JUNE   2000"      
  Matches:   JANUARY   2000|||19-01-2000|||12/11/2000    
  Non-Matches:   "Hello   it   is   ordinary   text"|||"non   -date   text"    
       
  Author:   Manpreet   Grewal   Rating:        
     
  Title:   Pattern   Title   [Details]   [Test]      
  Expression:   (?n:^(?="d)((?<month>(0?[13578])|1[02]|(0?[469]|11)(?!.31)|0?2(?(.29)(?=.29.((1[6-9]|[2-9]"d)(0[48]|[2468][048]|[13579][26])|(16|[2468][048]|[3579][26])00))|(?!.3[01])))(?<sep>[-./])(?<day>0?[1-9]|[12]"d|3[01])"k<sep>(?<year>(1[6-9]|[2-9]"d)"d{2})(?(?="x20"d)"x20|$))?(?<time>((0?[1-9]|1[012])(:[0-5]"d){0,2}(?i:"x20[AP]M))|([01]"d|2[0-3])(:[0-5]"d){1,2})?$)      
       
  Description:   New   DateTime   Regex.   Rebuilt   better   than   before,   better,   stronger,   faster.   Please   see   comments   below.   This   regex   will   validate   a   date,   time   or   a   datetime.   It   will   also   capture   the   date   fields   and   the   time.   Dates   are   in   the   MM/DD/YYYY   format   and   validated   for   months,   number   of   days   in   a   month   and   leap   years   (2/29)   Month   and   day   field   less   than   10   may   have   a   leading   0.   Years   are   4   digits.   Range   1600-9999   Date   field   can   be   separted   by   matched   periods(.),   dashes(-)   or   forward   slashes(/).   Time   is   either   12   hour   AM/PM   format   (HH:mm:ss   AM),   where   minutes   and   seconds   are   optional.   AM   or   PM   required.   or   24   hour   military   format   (HH:mm:SS),   from   00:00:00   to   23:59:59,   where   hours   and   minutes   fields   are   required,   including   leading   0   for   hours   less   than   10.   Datetime   is   the   above   date   and   time   formats   separated   by   a   space,   with   the   date   first   (MM/DD/YYYY   HH:mm:SS)   !IMPORTANT   NOTE:   your   regex   engine   must   support   lookaheads   and   named   groups   to   use   this   expression   Also   this   version   allow   for   capture   of   the   date   parts   which   you   can   then   use   in   your   code   month   =   "1   sep   =   "2   day   =   "3   year   =   "4   time   =   "5    
  Matches:   1/31/2002   10   AM|||2/29/2004|||4:15:04   PM    
  Non-Matches:   2/29/2003|||12/32/2003|||4:00    
       
  Author:   Michael   Ash   Rating:        
     
  Title:   Pattern   Title   [Details]   [Test]      
  Expression:   (?n:^(?="d)((?<day>31(?!(.0?[2469]|11))|30(?!.0?2)|29(?(.0?2)(?=.{3,4}(1[6-9]|[2-9]"d)(0[48]|[2468][048]|[13579][26])|(16|[2468][048]|[3579][26])00))|0?[1-9]|1"d|2[0-8])(?<sep>[/.-])(?<month>0?[1-9]|1[012])"2(?<year>(1[6-9]|[2-9]"d)"d{2})(?:(?="x20"d)"x20|$))?(?<time>((0?[1-9]|1[012])(:[0-5]"d){0,2}(?i:"   [AP]M))|([01]"d|2[0-3])(:[0-5]"d){1,2})?$)      
       
  Description:   DD/MM/YYYY   format   New   DateTime   Regex.   Rebuilt   better   than   before,   better,   stronger,   faster.   This   regex   will   validate   a   date,   time   or   a   datetime.   It   will   also   capture   the   date   fields   and   the   time.   Dates   are   in   the   DD/MM/YYYY   format   and   validated   for   months,   number   of   days   in   a   month   and   leap   years   (29/2)   Date   field   can   be   separated   by   matched   periods(.),   dashes(-)   or   forward   slashes(/).   Year   range   1600-9999   Time   is   either   12   hour   AM/PM   format   (HH:mm:ss   AM),   where   minutes   and   seconds   are   optional.   AM   or   PM   required.   or   24   hour   military   format   (HH:mm:SS),   from   00:00:00   to   23:59:59,   where   hours   and   minutes   fields   are   required,   including   leading   0   for   hours   less   than   10.   Datetime   is   the   above   date   and   time   formats   separated   by   a   space,   with   the   date   first   (DD/MM/YYYY   HH:mm:SS)   !IMPORTANT   NOTE:   your   regex   engine   must   support   lookaheads   and   named   groups   to   use   this   expression    
  Matches:   31/12/2003|||29/2/2004   4:50   PM|||23:59:59    
  Non-Matches:   12/31/2003|||29/2/2003|||4:00    
       
  Author:   Michael   Ash   Rating:        
     
  Title:   Pattern   Title   [Details]   [Test]      
  Expression:   ^(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)",*"s"s*"d{4}$|^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)",*"s"d{4}$|^(January|February|March|April|May|June|July|August|September|October|November|December)",*"s"d{4}$|^(january|february|march|april|may|june|july|august|september|october|november|december)",*"s"d{4}$      
       
  Description:   Best   Use   validation   to   accept   a   valid   "MonthName(,)   Year".   It   can   validate   an   entry   with   or   without   comma   (,).      
  Matches:   January   2004|||Jan,   2004|||january   2003    
  Non-Matches:   Janu   2004|||jAn,   2004|||January,2003    
       
  Author:   Elmer   Cadelina   Rating:   Not   yet   rated.      
     
  Title:   Pattern   Title   [Details]   [Test]      
  Expression:   ^([0-9]{2})(00[1-9]|0[1-9][0-9]|[1-2][0-9][0-9]|3[0-5][0-9]|36[0-6])$      
       
  Description:   Matches   a   Julian   date   in   the   format   YYDDD.   Two   digit   year   followed   by   a   number   from   1   -   366   indicating   the   day   of   the   year.    
  Matches:   99366|||00001    
  Non-Matches:   74000|||04367    
       
  Author:   Brian   James   Rating:   Not   yet   rated.      
     
  Title:   Pattern   Title   [Details]   [Test]      
  Expression:   ^((31(?!   (FEB|APR|JUN|SEP|NOV)))|((30|29)(?!   FEB))|(29(?=   FEB   (((1[6-9]|[2-9]"d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)))))|(0?[1-9])|1"d|2[0-8])   (JAN|FEB|MAR|MAY|APR|JUL|JUN|AUG|OCT|SEP|NOV|DEC)   ((1[6-9]|[2-9]"d)"d{2})$      
       
  Description:   Validates   date   format   by   DD   MMM   YYYY.   Validates   days   for   each   month   also.   Ensures   that   month   is   uppercase.    
  Matches:   09   MAY   1981|||28   JAN   2004|||8   JUL   2006    
  Non-Matches:   29   FEB   2003|||28   Oct   2000|||9   APR   03    

     

 

Title:   Pattern   Title   [Details]   [Test]      
  Expression:   ^"d{1,2}"/"d{1,2}"/"d{4}$      
       
  Description:   This   regular   expressions   matches   dates   of   the   form   XX/XX/YYYY   where   XX   can   be   1   or   2   digits   long   and   YYYY   is   always   4   digits   long.    
  Matches:   4/1/2001|||12/12/2001|||55/5/3434    
  Non-Matches:   1/1/01|||12   Jan   01|||1-1-2001    
       
  Author:   Steven   Smith   Rating:        
     
  Title:   Pattern   Title   [Details]   [Test]      
  Expression:   ^(([0-2]"d|[3][0-1])"/([0]"d|[1][0-2])"/[2][0]"d{2})$|^(([0-2]"d|[3][0-1])"/([0]"d|[1][0-2])"/[2][0]"d{2}"s([0-1]"d|[2][0-3])":[0-5]"d":[0-5]"d)$      
       
  Description:   Correct   French   DateTime(DD/MM/YYYY   OR   DD/MM/YYYY   HH:MM:SS)    
  Matches:   12/01/2002|||12/01/2002   12:32:10    
  Non-Matches:   32/12/2002|||12/13/2001|||12/02/06    
       
  Author:   Samir   AZZA   Rating:        
     
  Title:   Pattern   Title   [Details]   [Test]      
  Expression:   ^(((((0[13578])|([13578])|(1[02]))["-"/"s]?((0[1-9])|([1-9])|([1-2][0-9])|(3[01])))|((([469])|(11))["-"/"s]?((0[1-9])|([1-9])|([1-2][0-9])|(30)))|((02|2)["-"/"s]?((0[1-9])|([1-9])|([1-2][0-9]))))["-"/"s]?"d{4})("s(((0[1-9])|([1-9])|(1[0-2]))":([0-5][0-9])(("s)|(":([0-5][0-9])"s))([AM|PM|am|pm]{2,2})))?$      
       
  Description:   Following   expression   can   be   used   to   validate   a   datetime   column   from   SQL   Server.   This   expression   is   an   enhanced   version   of   Scott   Watermasysk's   date/time   submission.   It   now   accepts   leading   zeros   in   months,   days,   and   hours.   In   addition,   this   expression   properly   handles   the   11th   hour.   Watermasysk's   would   take   the   10th   and   12th   hour   but   not   the   11th.   This   regex   has   been   tweaked   to   do   so.   Does   not   handle   the   February   29th   problem   on   non-leap   years   yet.   Will   learn   a   little   more   about   RegEx   and   do   so   in   later   submission.      
  Matches:   11/30/2003   10:12:24   am|||2/29/2003   08:14:56   pm|||5/22/2003    
  Non-Matches:   11/31/2003   10:12:24   am|||2/30/2003   08:14:56   pm|||5/22/2003   14:15    
       
  Author:   David   Darling   Rating:        
     
  Title:   Pattern   Title   [Details]   [Test]      
  Expression:   ^["w-".]+@(["w-]+".)+["w-]{2,3}$      
       
  Description:   For   Date   format   MM-JJ-YYYY   validation      
  Matches:   umtsfr@free.fr|||123@dz.com|||regexlib@regexlib.fr    
  Non-Matches:   umtsfr@free|||umtsfrfree.fr|||@free.fr    
       
  Author:   Hakim   SALHI   Rating:   Not   yet   rated.      
     
  Title:   DateTime   M/d/y   hh:mm:ss   [Details]   [Test]      
  Expression:   ^(?="d)(?:(?:(?:(?:(?:0?[13578]|1[02])("/|-|".)31)"1|(?:(?:0?[1,3-9]|1[0-2])("/|-|".)(?:29|30)"2))(?:(?:1[6-9]|[2-9]"d)?"d{2})|(?:0?2("/|-|".)29"3(?:(?:(?:1[6-9]|[2-9]"d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))|(?:(?:0?[1-9])|(?:1[0-2]))("/|-|".)(?:0?[1-9]|1"d|2[0-8])"4(?:(?:1[6-9]|[2-9]"d)?"d{2}))($|"   (?="d)))?(((0?[1-9]|1[012])(:[0-5]"d){0,2}("   [AP]M))|([01]"d|2[0-3])(:[0-5]"d){1,2})?$      
       
  Description:   DateTime   Validator.      
  Matches:   12/25/2003|||08:03:31|||02/29/2004   12   AM    
  Non-Matches:   02/29/2003   1:34   PM|||13:23   PM|||24:00:00    
       
  Author:   Michael   Ash   Rating:        
     
  Title:   Time   [Details]   [Test]      
  Expression:   ^((0?[1-9]|1[012])(:[0-5]"d){0,2}("   [AP]M))$|^([01]"d|2[0-3])      
       
  Description:   This   RE   validates   times   patterns.    
  Matches:   1   AM|||23:00:00|||5:29:59   PM    
  Non-Matches:   13   PM|||13:60:00|||00:00:00   AM    
       
  Author:   Michael   Ash   Rating:        
     
  Title:   Pattern   Title   [Details]   [Test]      
  Expression:   (((0[1-9]|[12][0-9]|3[01])([/])(0[13578]|10|12)([/])("d{4}))|(([0][1-9]|[12][0-9]|30)([/])(0[469]|11)([/])("d{4}))|((0[1-9]|1[0-9]|2[0-8])([/])(02)([/])("d{4}))|((29)(".|-|"/)(02)([/])([02468][048]00))|((29)([/])(02)([/])([13579][26]00))|((29)([/])(02)([/])([0-9][0-9][0][48]))|((29)([/])(02)([/])([0-9][0-9][2468][048]))|((29)([/])(02)([/])([0-9][0-9][13579][26])))      
       
  Description:   Date   in   DD/MM/YYYY   format.   Fecha   en   formato   DD/MM/AAAA.    
  Matches:   28/12/2003|||28/02/2003|||29/02/2000    
  Non-Matches:   28-02-2003|||30/02/2003|||28.02.2003    
       
  Author:   Mathews   Inga   Rating:        
     
  Title:   Pattern   Title   [Details]   [Test]      
  Expression:   ^((((((0?[13578])|(1[02]))["-"/"s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))["-"/"s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2["-"/"s]?((0?[1-9])|([1-2][0-9]))))["-"/"s]?"d{2}(([02468][048])|([13579][26])))|(((((0?[13578])|(1[02]))["-"/"s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))["-"/"s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2["-"/"s]?((0?[1-9])|(1[0-9])|(2[0-8]))))["-"/"s]?"d{2}(([02468][1235679])|([13579][01345789]))))("s(((0?[1-9])|(1[0-2]))":([0-5][0-9])(("s)|(":([0-5][0-9])"s))([AM|PM|am|pm]{2,2})))?$      
       
  Description:   This   regex   will   match   SQL   Server   datetime   values,   allowing   date   only,   allowing   zero   padded   digits   in   month,   day   and   hour,   and   will   match   leap   years   from   1901   up   until   2099.    
  Matches:   2/29/2004|||04/01/2003   10:01:23   am|||03-20-1999    
  Non-Matches:   2/29/2003|||13/30/2001   10:05:00   pm|||12/32/2003    
       
  Author:   Sung   Lee   Rating:        
     
  Title:   Pattern   Title   [Details]   [Test]      
  Expression:   ^(("d{2}(([02468][048])|([13579][26]))["-"/"s]?((((0?[13578])|(1[02]))["-"/"s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))["-"/"s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2["-"/"s]?((0?[1-9])|([1-2][0-9])))))|("d{2}(([02468][1235679])|([13579][01345789]))["-"/"s]?((((0?[13578])|(1[02]))["-"/"s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))["-"/"s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2["-"/"s]?((0?[1-9])|(1[0-9])|(2[0-8]))))))("s(((0?[1-9])|(1[0-2]))":([0-5][0-9])(("s)|(":([0-5][0-9])"s))([AM|PM|am|pm]{2,2})))?$      
       
  Description:   Matches   ANSI   SQL   date   format   YYYY-mm-dd   hh:mi:ss   am/pm.   You   can   use   /   -   or   space   for   date   delimiters,   so   2004-12-31   works   just   as   well   as   2004/12/31.   Checks   leap   year   from   1901   to   2099.    
  Matches:   2004-2-29|||2004-02-29   10:29:39   pm|||2004/12/31    
  Non-Matches:   2003-2-29|||2003-13-02|||2003-2-2   10:72:30   am    
       
  Author:   Sung   Lee   Rating:        
     
  Title:   Pattern   Title   [Details]   [Test]      
  Expression:   ^(([0]?[1-9]|1[0-2])/([0-2]?[0-9]|3[0-1])/[1-2]"d{3})?   ?((([0-1]?"d)|(2[0-3])):[0-5]"d)?(:[0-5]"d)?   ?(AM|am|PM|pm)?$      
       
  Description:   Matches   variations   on   date/time/AM-PM.   Must   have   4   digit   year,   but   everything   else   is   open.   Restrictions   are:   4   digit   year,   months   1-12,   hours   1-23,   minutes   and   seconds   1-59,   any   case   of   AM   and   PM.   If   this   don't   woik,   I   wrote   it,   lemmy   know.    
  Matches:   12/30/2002|||12/30/2002   9:35   pm|||12/30/2002   19:35:02    
  Non-Matches:   18/22/2003|||8/12/99|||8/22/2003   25:00    
       
  Author:   Michael   Gaertner   Rating:   Not   yet   rated.     
 

posted on 2009-02-27 16:30  善为  阅读(1107)  评论(0编辑  收藏  举报