467,911 Members | 1,354 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,911 developers. It's quick & easy.

Date Validator Regex with format dd-MMM-yyyy, Zero Date

Hi Guys,

This is regular expression for validating dd-MMM-yyyy date format:

^(0[1-9]|[1-9]|[12][0-9]|3[01])-([Jj][Aa][Nn]|[Ff][Ee][Bb]|[Mm][Aa][Rr]|[Aa][Pp][Rr]|[Mm][Aa][Yy]|[Jj][Uu][Nn]|[Jj][Uu][Lj]|[Aa][Uu][Gg]|[Ss][Ee][Pp]|[Oo][Cc][Tt]|[Nn][Oo][Vv]|[Dd][Ee][Cc])-(19|20)\d\d$

It will not allow case like 0-Aug-2007, should be 01-Aug-2007

Thanks,
Martin
Aug 22 '07 #1
  • viewed: 11293
Share:
2 Replies
kenobewan
Expert 4TB
The date format is dd-MM-yyyy. Maybe if you want to format dates this way you need to include globalization in your validation. HTH.
Aug 22 '07 #2
Hi!

I'm not sure what the question is but my first reaction was that it would be much easier to parse for human eyes if written as:

^(0?[1-9]|[12][0-9]|3[01])-(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)-(19|20)\d\d$

and then made case insensitive by setting RegexOptions.IgnoreCase

(see http://msdn2.microsoft.com/en-us/lib...exoptions.aspx)

Hi Guys,

This is regular expression for validating dd-MMM-yyyy date format:

^(0[1-9]|[1-9]|[12][0-9]|3[01])-([Jj][Aa][Nn]|[Ff][Ee][Bb]|[Mm][Aa][Rr]|[Aa][Pp][Rr]|[Mm][Aa][Yy]|[Jj][Uu][Nn]|[Jj][Uu][Lj]|[Aa][Uu][Gg]|[Ss][Ee][Pp]|[Oo][Cc][Tt]|[Nn][Oo][Vv]|[Dd][Ee][Cc])-(19|20)\d\d$

It will not allow case like 0-Aug-2007, should be 01-Aug-2007

Thanks,
Martin
Aug 22 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Bryce Budd | last post: by
8 posts views Thread by Dmitry Korolyov | last post: by
3 posts views Thread by Mad Scientist Jr | last post: by
1 post views Thread by spalding | last post: by
2 posts views Thread by JebBushell | last post: by
15 posts views Thread by morleyc | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.