Regex for date (DD/MM/YYYY)

Use /^(?:0[1-9]|[12]\d|3[01])\/(?:0[1-9]|1[0-2])\/\d{4}$/ to check that a whole string is a valid for date (DD/MM/YYYY). Every example below is tested against the pattern, and you can open it in the Regex Tester with the samples preloaded.

Updated

/^(?:0[1-9]|[12]\d|3[01])\/(?:0[1-9]|1[0-2])\/\d{4}$/
Open in Regex Tester
InputResult
30/10/2026✓ Match
01/12/2000✓ Match
31/01/1999✓ Match
10/30/2026✗ No match
1/5/2026✗ No match
30-10-2026✗ No match
32/01/2026✗ No match

How the pattern works

PartMeaning
(?:0[1-9]|[12]\d|3[01])Day 01–31 first (UK, European, Indian and Australian order)
\/A slash
(?:0[1-9]|1[0-2])Month 01–12
\d{4}$Four-digit year

Code examples

JavaScript

const re = /^(?:0[1-9]|[12]\d|3[01])\/(?:0[1-9]|1[0-2])\/\d{4}$/;
re.test(value); // true or false

Python

import re

bool(re.fullmatch(r'(?:0[1-9]|[12]\d|3[01])/(?:0[1-9]|1[0-2])/\d{4}', value))

PHP

preg_match('/^(?:0[1-9]|[12]\d|3[01])\/(?:0[1-9]|1[0-2])\/\d{4}$/', $value) === 1;

Notes and limitations

Swap \/ for [\/.-] to accept 30.10.2026 and 30-10-2026 as well. Days per month aren’t checked.

Regex TesterType a pattern and watch matches highlight live in your test text.
Open the tool

Frequently asked questions

What is the regex for date (DD/MM/YYYY)?
/^(?:0[1-9]|[12]\d|3[01])\/(?:0[1-9]|1[0-2])\/\d{4}$/ — it matches the whole string. See the table above for what each part does.
Which examples match?
Of the examples tested, these match: 30/10/2026, 01/12/2000, 31/01/1999. The others don’t.
How do I test this regex?
Click “Open in Regex Tester” — the pattern, flags and sample text load automatically, and matches highlight as you edit.