Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
PCRE2 (PHP >=7.3)

/
^((([D]{1,4}|[M]{1,4}|[Y]{2}|[Y]{4})([D]{1,4}|[M]{1,4}|[Y]{2}|[Y]{4}))([D]{1,4}|[M]{1,4}|[Y]{2}|[Y]{4}))$
/
gm

Description

For the day: d Displays the day as a number without a leading zero (1-31). dd Displays the day as a number with a leading zero (01-31). ddd Displays the day as an abbreviation (Sun-Sat) dddd Displays the day as a full name (Sunday-Saturday)

For the month: m Displays the month as a number without a leading zero (1-12). mm Displays the month as a number with a leading zero (01-12). mmm Displays the month as an abbreviation (Jan-Dec). mmmm Displays the month as a full name (January-December).

For the year: yy Displays the year as a two-digit number (00-99). yyyy Displays the year as a four-digit number (0000-9999).

Submitted by EYA GHACHEM - a year ago