Regex for Matching a Date (MM/DD/YYYY)
Matches dates in the common US slash-separated format.
Published October 10, 2026
This regex matches US-style dates in MM/DD/YYYY with plausible ranges for month and day.
How the pattern works
Breaking the pattern down: 0[1-9]|1[0-2] = month; 0[1-9]|[12]\d|3[01] = day; \d{4} = year.
Test your regex against both matching and non-matching inputs; use the Regex tool on this site to experiment live.
Pattern tests
/^(0[1-9]|1[0-2])/(0[1-9]|[12]\d|3[01])/\d{4}$/
✓ '11/12/2026'
✓ '01/31/1999'
✗ '13/01/2026'
✗ '11/32/2026'
Practical examples
The pattern
const re = /^(0[1-9]|1[0-2])/(0[1-9]|[12]\d|3[01])/\d{4}$/Test it
const re = /^(0[1-9]|1[0-2])/(0[1-9]|[12]\d|3[01])/\d{4}$/
re.test('11/12/2026') // true
re.test('01/31/1999') // true
re.test('13/01/2026') // false
re.test('11/32/2026') // falseIn Python
import re
re.search(r'^(0[1-9]|1[0-2])/(0[1-9]|[12]\d|3[01])/\d{4}$', text)Common mistakes
- Not allowing single-digit months.
- Mixing DD/MM and MM/DD.
- Regex not validating leap years.
Key takeaways
- Anchors (^ and $) make the whole string match instead of a part of it.
- Regex checks format only; verify data separately when it matters.
- Test with valid and invalid samples.
FAQ
Allow single digits?
Use (0?[1-9]|1[0-2]) for flexible months.
Where can I test this pattern?
Use the Regex Tester on this site, or regex101.com.