Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
PCRE (PHP <7.3)

/
^(((0?[1-9]|1\d|2[0-8])\.(0?[1-9]|1[012])|(29|30)\.(0?[13456789]|1[012])|31\.(0?[13578]|1[02]))\.(19|[2-9]\d)\d{2}|29\.0?2\.((19|[2-9]\d)(0[48]|[2468][048]|[13579][26])|(([2468][048]|[3579][26])00)))$
/

Description

Following inputs are accepted dd.mm.yyyy

while 29.02.2016 accepted, 29.02.2017 is not. also some months last days should be 30, not 31

ex: 31.11.2016 not accepted

Submitted by Abdulhamit Mabocoglu - 8 years ago