Start free · Free tools · Fair usage limits
Browse Tools

Categories

Custom AI Solutions – AI2Flows
LIVE NEWS
Loading latest AI & SEO news…
Home›Tools›Regex Tester›Regex for date (DD/MM/YYYY)
Regex pattern · validation

Regex for date (DD/MM/YYYY)

Regex for date DD/MM/YYYY: a tested pattern with examples, a plain-English breakdown, and code for JavaScript, Python, PHP, Java and Go.

Quick answer

Use /^(?:0[1-9]|[12]\d|3[01])\/(?:0[1-9]|1[0-2])\/\d{4}$/ as a date (DD/MM/YYYY) regex. It matches "25/11/2026" and "01/01/1999", and rejects "32/01/2026" and "25/13/2026". Swap \/ for [\/.-] to also accept 25.11.2026 or 25-11-2026.

Last updated · Maintained by FreeAIToolz · How we test

/^(?:0[1-9]|[12]\d|3[01])\/(?:0[1-9]|1[0-2])\/\d{4}$/
  • 25/11/2026matches
  • 01/01/1999matches
  • 32/01/2026no match
  • 25/13/2026no match
  • 25-11-2026no match
  • 2026/11/25no match
Open in the full Regex Tester (replace, flags, groups) →

How this regex works

PartMeaning
(?:0[1-9]|[12]\d|3[01])day 01–31
\/slash
(?:0[1-9]|1[0-2])month 01–12
\/\d{4}$slash and four-digit year

Examples

InputResult
25/11/2026✓ Matches
01/01/1999✓ Matches
32/01/2026✗ No match
25/13/2026✗ No match
25-11-2026✗ No match
2026/11/25✗ No match

Every example above is checked automatically in JavaScript and Python each time the site is built.

Limitations and edge cases

Swap \/ for [\/.-] to also accept 25.11.2026 or 25-11-2026. Validate the real date after matching.

When to use this pattern

UK, European, Asian and Australian date inputs.

Use it in your language

JavaScript

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

Python

import re
pattern = re.compile(r'^(?:0[1-9]|[12]\d|3[01])\/(?:0[1-9]|1[0-2])\/\d{4}$')
bool(pattern.search(value))

PHP

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

Java

Pattern pattern = Pattern.compile("^(?:0[1-9]|[12]\\d|3[01])\\/(?:0[1-9]|1[0-2])\\/\\d{4}$");
boolean ok = pattern.matcher(value).find();

Go

re := regexp.MustCompile(`^(?:0[1-9]|[12]\d|3[01])\/(?:0[1-9]|1[0-2])\/\d{4}$`)
ok := re.MatchString(value)

More regex patterns

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}$/. Swap \/ for [\/.-] to also accept 25.11.2026 or 25-11-2026. Validate the real date after matching.
Which languages does this pattern work in?
It is tested in JavaScript and Python and uses syntax that also works in PHP (PCRE) and Java. It also works in Go’s RE2 engine.
Why does the pattern start with ^ and end with $?
They anchor the match to the whole string, so "abc25/11/2026xyz" cannot pass just because it contains a valid part. To search for matches inside longer text, remove ^ and $ (use \b where word boundaries help) and add the g flag.