Regex for date.

Posted by Harikrishna on Stack Overflow See other posts from Stack Overflow or by Harikrishna
Published on 2010-05-08T12:38:18Z Indexed on 2010/05/08 12:58 UTC
Read the original article Hit count: 487

Filed under:
|

What should be the regex for matching date of any format like

 26FEB2009 
 30 Jul 2009
 27 Mar 2008
 29/05/2008
 27 Aug 2009

What should be the regular expression for that ?

I have regex that matches with 26-Feb-2009 and 26 FEB 2009 with but not with 26FEB2009. So if any one know then please update it.

(?:^|[^\d\w:])(?'day'\d{1,2})(?:-?st\s+|-?th\s+|-?rd\s+|-?nd\s+|-|\s+)(?'month'Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)[uarychilestmbro]*(?:\s*,?\s*|-)(?:'?(?'year'\d{2})|(?'year'\d{4}))(?=$|[^\d\w])

EDIT The date 26FEB2009 is substring of other string like FUTIDX 26FEB2009 NIFTY 0 and parsed from html page, so I can not set the whitespace or delimiter.

© Stack Overflow or respective owner

Regex for date.

Posted by Harikrishna on Stack Overflow See other posts from Stack Overflow or by Harikrishna
Published on 2010-05-08T09:39:54Z Indexed on 2010/05/08 12:18 UTC
Read the original article Hit count: 489

Filed under:
|
|

What should be the regex for matching date of any format like

 26FEB2009 
 30 Jul 2009
 27 Mar 2008
 29/05/2008
 27 Aug 2009

What should be the regular expression for that ?

Edit I have regex that matches with 26-Feb-2009 and 26 FEB 2009 with but not with 26FEB2009. So if any one know then please update it.

(?:^|[^\d\w:])(?'day'\d{1,2})(?:-?st\s+|-?th\s+|-?rd\s+|-?nd\s+|-|\s+)(?'month'Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)[uarychilestmbro]*(?:\s*,?\s*|-)(?:'?(?'year'\d{2})|(?'year'\d{4}))(?=$|[^\d\w])

© Stack Overflow or respective owner

Related posts about c#

Related posts about regex