I came up with the following before which is not entirely correct.
^\d{2}/(\d{2})/(\d{4})+
Why? You can enter the date as 45\23\0088. This is just digit matching.
thus, i refactor to the following:
((0{1}[1-9])|([1-2][0-9])|(3{1}[0-1]))/((0{1}[1-9])|(1{1}[0-2]))/((19|20)\d\d)
This regex only allow you to enter
dd from 01-31.
mm from 01-09 and 11-12
yyyy range restricted to 19xx-20xx.
How to get it tested? Try the following flash regex engine:
http://gskinner.com/RegExr/
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment