
February 8th, 2011, 06:44 AM
|
|
|
|
Your requirement is ... well, horrible! Matching dates is bad enough without rolling in the fact that you'll accept dd/mm as well as mm/dd, with the month component also being an alpha abbreviation and the day having, or not, a leading zero.
I made a start, but gave up when my eyes started bleeding from trying to match up all the brackets as I started to build up the needed regex: and that was until (but not including the first year field!).
Don't try and be clever is my suggestion - go for basic checks and assume that the data is good, so look for 1 or 2 numerics, followed by a / or -, then one or two numerics (or 3 alpha) followed by a / or -, then 2 or 4 numerics and assume if that pattern matches it's a date, and so on.
__________________
The moon on the one hand, the dawn on the other:
The moon is my sister, the dawn is my brother.
The moon on my left and the dawn on my right.
My brother, good morning: my sister, good night.
-- Hilaire Belloc
|