Regex to Match MM/DD/YYYY Dates
Validate dates in MM/DD/YYYY format with this regex pattern. Checks valid month and day ranges using forward slash separators. Free regex tool.
Regular Expression
/^(?:0[1-9]|1[0-2])\/(?:0[1-9]|[12]\d|3[01])\/\d{4}$/
Token Breakdown
| Token | Description |
|---|---|
| ^ | Anchors at the start of the string (or line in multiline mode) |
| (?: | Start of non-capturing group |
| 0 | Matches the literal character '0' |
| [1-9] | Character class — matches any one of: 1-9 |
| | | Alternation — matches the expression before OR after the pipe |
| 1 | Matches the literal character '1' |
| [0-2] | Character class — matches any one of: 0-2 |
| ) | End of group |
| \/ | Matches a literal forward slash |
| (?: | Start of non-capturing group |
| 0 | Matches the literal character '0' |
| [1-9] | Character class — matches any one of: 1-9 |
| | | Alternation — matches the expression before OR after the pipe |
| [12] | Character class — matches any one of: 12 |
| \d | Matches any digit (0-9) |
| | | Alternation — matches the expression before OR after the pipe |
| 3 | Matches the literal character '3' |
| [01] | Character class — matches any one of: 01 |
| ) | End of group |
| \/ | Matches a literal forward slash |
| \d | Matches any digit (0-9) |
| {4} | Matches exactly 4 times |
| $ | Anchors at the end of the string (or line in multiline mode) |
Detailed Explanation
This regex validates dates in the MM/DD/YYYY format commonly used in the United States. Here is the token-by-token breakdown:
^ — Anchors the match at the start of the string.
(?:0[1-9]|1[0-2]) — A non-capturing group matching the month (01-12). It uses two alternatives: 0[1-9] for months 01-09 and 1[0-2] for months 10-12. Leading zeros are required, so '1/15/2024' would not match (it would need to be '01/15/2024').
/ — Matches a literal forward slash. The backslash escapes the slash, though in many regex flavors the escape is not strictly necessary.
(?:0[1-9]|[12]\d|3[01]) — A non-capturing group matching the day (01-31). Three alternatives cover the valid ranges: 0[1-9] for days 01-09, [12]\d for days 10-29, and 3[01] for days 30 and 31.
/ — Matches another literal forward slash.
\d{4} — Matches exactly four digits for the year.
$ — Anchors the match at the end of the string.
Like the YYYY-MM-DD pattern, this regex validates the format and basic ranges but does not check for month-specific day limits (e.g., February 30). The MM/DD/YYYY format is standard in the United States for dates on documents, forms, and casual communication. If you also need to accept single-digit months and days without leading zeros, modify the month group to (?:0?[1-9]|1[0-2]) and the day group to (?:0?[1-9]|[12]\d|3[01]).
Example Test Strings
| Input | Expected |
|---|---|
| 01/15/2024 | Match |
| 12/31/2023 | Match |
| 13/01/2024 | No Match |
| 1/5/2024 | No Match |
| 06/30/2024 | Match |
Try It — Interactive Tester
51 charsFlags: noneMatches: 0Ctrl+Shift+C to copy regex
Related Regex Patterns
Regex to Match YYYY-MM-DD Dates
/^\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])$/
Regex to Match ISO 8601 DateTime
/^\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])T(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d{1,3})?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/
Regex to Match 12-Hour Time Format
/^(?:0?[1-9]|1[0-2]):[0-5]\d(?::[0-5]\d)?\s?[AaPp][Mm]$/
Regex to Match 24-Hour Time Format
/^(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d)?$/