Regular Expression for matching dd/mm/yyyy format

10 06 2009

(0[1-9]|[12][0-9]|3[01])[/](0[1-9]|1[012])[/](19|20)[0-9]{2}

I’m not going to try and explain this regular expression as it is very clever and has been only very slightly modified from the one found here http://www.regular-expressions.info/regexbuddy/dateddmmyyyy.html

I have limited mine slightly more to only being allowed to use slashes and changed the end very slightly (although it means the same thing) and that site shows an excellent explanation. I simply want to post this here as I know I will want to use it in the future and I’m less likely to lose a blog post than a post it note 🙂

Advertisements