Regex to Match an MM/DD/YYYY Date
Copy the pattern, paste your text below, and see every US-format date it finds. Below the tester: how each group bounds the month and day, and what it does not check.
What this pattern matches
This expression matches dates written in the American month/day/year order, such as 09/28/2026. It bounds the month to 01–12 and the day to 01–31, so obviously wrong values like 13/40/2026 are skipped.
How it works, part by part
(0[1-9]|1[0-2]) — the month: 01 through 09, or 10 through 12.
(0[1-9]|[12][0-9]|3[01]) — the day: 01–09, 10–29, or 30–31.
\d{4} — a four-digit year.
What it does not check
It does not validate the number of days in a specific month, so 02/30/2026 still matches. Calendar-correct validation (leap years, 30-day months) is far easier in code than in one regex. Use this to find dates in text; validate the real calendar afterwards.
Use it in your code
import re
text = "Invoice dated 09/28/2026, shipped 12/01/2026. Bad: 13/40/2026 and 00/15/2026 should not match."
pattern = r'''(0[1-9]|1[0-2])/(0[1-9]|[12][0-9]|3[01])/\d{4}'''
for m in re.finditer(pattern, text):
print(m.group())
const text = "Invoice dated 09/28/2026, shipped 12/01/2026. Bad: 13/40/2026 and 00/15/2026 should not match.";
const re = new RegExp(String.raw`(0[1-9]|1[0-2])/(0[1-9]|[12][0-9]|3[01])/\d{4}`, "g");
console.log(text.match(re));
FAQ
Does it accept single-digit months like 9/28/2026?
No. It requires zero-padded two-digit months and days. Change 0[1-9] to 0?[1-9] if you want to allow 9/28/2026.
Will 02/30/2026 match?
Yes. The pattern bounds the day to 01–31 but does not know how many days each month has. Check the calendar in code after matching.
How do I match DD/MM/YYYY instead?
Swap the first two groups so the day (0[1-9]|[12][0-9]|3[01]) comes before the month (0[1-9]|1[0-2]).