Regular Expressions 101

Community Library Entry

0

Regular Expression
PCRE2 (PHP >=7.3)

/
^(?:(?:31(?:0[13578]|1[02])|(?:30|29)(?:0[13-9]|1[0-2])|(?:0[1-9]|1[0-9]|2[0-8])(?:0[1-9]|1[0-2]))[0-9]{2}-?[0-9]|290200-?[4-9]|2902(?:(?!00)[02468][048]|[13579][26])-?[0-3])[0-9]{3}|000000-?0000$
/
gm

Description

This one makes sure to not match 31 in months where it does not exist and cuts off february at 28. Might need to do special check for 29th of february ..?

Submitted by anonymous - 2 years ago