Tag: bissextile

Regular Expression – Regex – For Date Validation (Bissextile Included)

Hi all,

I found a good regex for date validation that consider bissextile. I tested and it works.

I have problems with the bellow expressions in the eclipse, because it don't support the expression (?:) Non-Capturing groups.
^(?:(?:(?:0[1-9]|1\d|2[0-8])/(?:0[1-9]|1[0-2])|(?:29|30)/(?:0[13-9]|1[0-2])|31/(?:0[13578]|1[02]))/\d{4}|29/02/(?:\d\d(?:0[48]|[2468][048]|[13579][26])|(?:[02468][048]|[13579][26])00))$

I discover another expression that works in the Eclipse:

^(((((0[1-9])|(1\d)|(2[0-8]))\/((0[1-9])|(1[0-2])))|((31\/((0[13578])|(1[02])))|((29|30)\/((0[1,3-9])|(1[0-2])))))\/(\d{4}))|((29\/02\/(\d{2})(([02468][048])|([13579][26]))))$

Both expressions are in the format: dd/mm/yyyy

Credits: http://www.perlmonks.org/?node_id=153702