Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
PCRE (PHP <7.3)

/
^(?=^(?:(\d\d(?:[02468][048]|[13579][26]))-02-29|\d{4}-(?:0[13578]|1[02])-31|\d{4}-(?:0[13-9]|1[0-2])-30|\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|1\d|2[0-8])))(\d{4})-(\d\d?)-(\d\d?)(?:\x20(\d{2}):(\d{2})(?::(\d{2})(.\d+)?)?)?$
/
gm

Description

Works for the Julian calendar, dates between 0000-01-01 and 9999-12-31. Includes my birth date in the 4th example.

Submitted by luis140219 on GitHub - 10 years ago