How the pattern works
| Part | Meaning |
|---|---|
(?: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 falsePython
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.