~/regex-tester

Match ISO 8601 dates with regex

A regex for the calendar-date form of ISO 8601, with named groups for year, month, and day. Notes on full ISO 8601 (timestamp + timezone) and what regex cannot validate.

# pattern

/(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})/g

→ Open in regex tester (pre-filled)

# how it works

Three named capture groups: year (4 digits), month (2 digits), day (2 digits). Use back-references `$<year>`, `$<month>`, `$<day>` in replacements.

# sample input

Born 1991-07-04. Released on 2026-05-14 and patched 2026-06-01. Not a date: 26/05/2026.

# pitfalls

# other patterns