What do you mean by validate? If you simply mean 'make sure it is 4 digits followed by a dash followed by 2 digits followed by a dash followed by 2 digits' then a simple regex would work fine. If you want to get into checking to make sure that the second two digits are between 1 and 12 or that if the second two digits are 2, then the last two digits must be between 1 and 28 unless the first 4 digits are divisible by 4 then between 1 and 29, then a regex will still work, but it would be easier IMO to split the string and validate each piece.
[blue]"Well, once again my friend, we find that science is a two headed beast. One head is nice, it gives us aspirin and other modern conveniences,...but the other head of science is BAD! Oh, beware the other head of science, Arthur; it bites!!" - The Tick[/blue]
I'm simply looking basic regex to check if the date as the corrent format xxxx-xx-xx (x = digits) I don't wanna check if the numbers are valid or not...
But it will depend on if the day and month values will be padded or not.
[blue]"Well, once again my friend, we find that science is a two headed beast. One head is nice, it gives us aspirin and other modern conveniences,...but the other head of science is BAD! Oh, beware the other head of science, Arthur; it bites!!" - The Tick[/blue]
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.