Regex for date (MM/DD/YYYY)

Use /^(?:0[1-9]|1[0-2])\/(?:0[1-9]|[12]\d|3[01])\/\d{4}$/ to check that a whole string is a valid for date (MM/DD/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]|1[0-2])\/(?:0[1-9]|[12]\d|3[01])\/\d{4}$/
Open in Regex Tester
InputResult
10/30/2026✓ Match
01/01/2000✓ Match
12/31/1999✓ Match
13/01/2026✗ No match
1/5/2026✗ No match
30/10/2026✗ No match
10-30-2026✗ No match

How the pattern works

PartMeaning
(?:0[1-9]|1[0-2])Month 01–12 first (US order)
\/A slash (escaped for JavaScript literals)
(?:0[1-9]|[12]\d|3[01])Day 01–31
\d{4}$Four-digit year at the end

Code examples

JavaScript

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

Python

import re

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

PHP

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

Notes and limitations

To also accept single-digit months and days, change 0[1-9] to 0?[1-9] in both places. Days per month aren’t checked, so validate the date itself afterwards.

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 (MM/DD/YYYY)?
/^(?:0[1-9]|1[0-2])\/(?:0[1-9]|[12]\d|3[01])\/\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: 10/30/2026, 01/01/2000, 12/31/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.