Regex for Matching a Date (YYYY-MM-DD)

Matches dates in ISO 8601 format.

Published October 10, 2026

Matches dates in ISO 8601 format.

Key points

  • Checks the shape only — it will match an invalid date like 2024-13-40
  • For real validation, parse the string with a date library after the shape check passes

Example

^\d{4}-\d{2}-\d{2}$
More General articles