US Date Regex (MM/DD/YYYY)
Validates a calendar date in the US MM/DD/YYYY format with slash separators, requiring zero-padded month and day values.
Regex Pattern
^(0[1-9]|1[0-2])/(0[1-9]|[12]\d|3[01])/\d{4}$Pattern Breakdown
Hover over a token to see what it does.
| Token | Meaning |
|---|---|
| ^ | Anchors the match to the start of the string. |
| (0[1-9]|1[0-2]) | The month: 01-09 or 10-12. |
| / | A literal forward slash separating the date components. |
| (0[1-9]|[12]\d|3[01]) | The day: 01-09, 10-29, or 30-31. |
| \d{4} | Exactly four digits for the year. |
| $ | Anchors the match to the end of the string. |
Detailed Explanation
What it does
This pattern matches dates written in the US convention MM/DD/YYYY, such as 07/10/2026. It requires a zero-padded two-digit month between 01 and 12, a zero-padded two-digit day between 01 and 31, and a four-digit year, all separated by forward slashes.
Why it works
The month and day are each validated with their own alternation of digit ranges rather than a generic `\d{2}`, which keeps invalid values like month 13 or day 32 out. Because regex has no calendar awareness, the day range 30-31 is accepted regardless of which month precedes it, so month-specific day limits and leap years are not enforced.
Common use cases
- Validating US-formatted date fields in web and desktop forms
- Pre-checking spreadsheet or CSV imports that use MM/DD/YYYY dates
- Filtering log files or filenames that embed a US-style date
- Guarding a date parser input before handing it to a full date library
Edge cases
- 02/30/2026 matches even though February never has 30 days, because the pattern only checks digit ranges
- 04/31/2026 matches even though April has only 30 days, since month-day correlation isn't representable with this regex alone
- Single-digit months or days without a leading zero, like 1/5/2026, correctly fail to match
- Two-digit years such as 01/15/26 correctly fail because exactly four digits are required for the year
Limitations
- Does not validate real calendar correctness, such as leap years or month-specific day counts
- Only supports the slash-separated MM/DD/YYYY order, not other regional orderings like DD/MM/YYYY
- Does not support a time component or timezone information
Interactive Tester
Edit the pattern or text below — matching runs live in your browser.
Test Cases
Editable — add your own inputs to see if they pass.
| Input | Expected | Result | |
|---|---|---|---|
| Pass | |||
| Pass | |||
| Pass | |||
| Pass | |||
| Pass | |||
| Pass | |||
| Pass | |||
| Pass |
Language Variants
Production-ready examples in 12 languages.
const usDatePattern = /^(0[1-9]|1[0-2])\/(0[1-9]|[12]\d|3[01])\/\d{4}$/;
function isValidUsDate(value) {
return usDatePattern.test(value);
}
console.log(isValidUsDate("07/10/2026")); // trueCommon Mistakes
Assuming a regex match guarantees a real calendar date, so invalid combinations like 02/30 slip through.
Fix: Use the regex as a format pre-check only, then parse with a date library and confirm the value round-trips to the same date.
Forgetting that this pattern requires zero-padded month and day, rejecting inputs like 7/10/2026.
Fix: Either pre-pad user input with leading zeros before validating, or relax the groups to `\d{1,2}` if single digits should be accepted.
Confusing MM/DD/YYYY with the DD/MM/YYYY order used in many other locales.
Fix: Clearly label the expected format in the UI, or detect locale and swap to a DD/MM/YYYY variant when appropriate.
Performance Notes
- All quantifiers are bounded (`{4}`, fixed alternation branches), so matching runs in linear time with no catastrophic backtracking risk.
- Anchors at both ends let the engine reject wrong-length input immediately.
- The month and day alternations are mutually exclusive by leading digit, so backtracking between branches is minimal.
Browser Compatibility
| Engine | Supported | Notes |
|---|---|---|
| Chrome | Yes | — |
| Firefox | Yes | — |
| Safari | Yes | — |
| Edge | Yes | — |
| Node.js | Yes | — |