日期替换,正则

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   

未测试。。。

posted on 2011-04-03 19:13 zqonline 阅读(...) 评论(...) 编辑 收藏

导航