Regular Expressions 101

Community Patterns

Match user defined date format

0

Regular Expression
PCRE2 (PHP >=7.3)

/
\(20(\d{2}|x{2})((\.|-)([0-9]{2}|x{2}|KW(\d{2}|x{2})|Q(x|[1-4])|(([0-9]{2}|x{2})(\.|-)([0-9]{2}|x{2}))))?\)
/
g

Description

Only matches, when date is in brackets. Allows for KW/CW or Q or normal date. Delimiters are '.' & '-'; Does not work for years < 2000 and does not validate for correct month- or day-values (except quarter).

Submitted by MjSt - 2 years ago