Visual regex workbench

Build, import, explain, test and share regex visually.

Regex guide

Date Regex Examples

Date validation is one of the most common regex use cases. This guide provides practical date regex examples covering European formats, ISO standards and timestamps.

DD/MM/YYYY

Matches dates written with slashes.

Suggested pattern

^\d{2}\/\d{2}\/\d{4}$
Quick test

What it matches

  • 31/12/2025
  • 01/01/2026

Common limitations

  • Does not validate real calendar dates.
  • 31/99/2025 still matches.

DD-MM-YYYY

Matches dates written with hyphens.

Suggested pattern

^\d{2}-\d{2}-\d{4}$
Quick test

What it matches

  • 31-12-2025
  • 01-01-2026

Common limitations

  • Does not validate month or day ranges.

ISO date

Matches ISO 8601 dates.

Suggested pattern

^\d{4}-\d{2}-\d{2}$
Quick test

What it matches

  • 2025-12-31
  • 2026-01-01

Common limitations

  • Does not verify actual calendar validity.

ISO datetime

Matches UTC timestamps ending with Z.

Suggested pattern

^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$
Quick test

What it matches

  • 2025-12-31T23:59:59Z

Common limitations

  • Only accepts UTC timestamps with seconds.

Stricter DD/MM/YYYY

Validates day and month ranges.

Suggested pattern

^(0[1-9]|[12][0-9]|3[01])\/(0[1-9]|1[0-2])\/\d{4}$
Quick test

What it matches

  • 31/12/2025
  • 01/01/2026

Common limitations

  • Still accepts impossible dates such as 31/02/2025.

Why validate dates with regex?

Date regex patterns are commonly used to verify user input before processing, storing or converting dates.

They help ensure that values follow an expected format such as YYYY-MM-DD, DD/MM/YYYY or MM/DD/YYYY.

Common date formats

Different countries and applications use different date formats. ISO 8601 typically uses YYYY-MM-DD, while many European countries use DD/MM/YYYY.

Understanding the expected format is essential before creating a date validation regex.

ISO 8601 date validation

ISO 8601 is one of the most widely used date formats in APIs, databases and software systems.

The YYYY-MM-DD format is easy to sort, compare and exchange between applications.

Can regex validate real calendar dates?

A regex can validate the structure of a date, but fully validating calendar rules is much more difficult.

For example, checking leap years, month lengths and historical calendar rules is usually better handled by dedicated date libraries.

Date format validation vs date parsing

Regex is excellent for checking whether a date looks correct, but parsing and interpreting dates should generally be handled by programming language date functions.

Combining regex validation with proper date parsing often provides the best results.

Common date validation mistakes

One common mistake is accepting impossible dates such as 2026-02-31 or 31/04/2026.

Another is mixing international date formats and creating ambiguity between month and day values.

When to use a date regex

Date regex patterns are useful in forms, imports, spreadsheets, APIs and data-cleaning workflows.

They provide a fast first layer of validation before more advanced business rules are applied.