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

TokenDescription
^Anchors at the start of the string (or line in multiline mode)
(?:Start of non-capturing group
0Matches the literal character '0'
[1-9]Character class — matches any one of: 1-9
|Alternation — matches the expression before OR after the pipe
1Matches 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
0Matches 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
\dMatches any digit (0-9)
|Alternation — matches the expression before OR after the pipe
3Matches the literal character '3'
[01]Character class — matches any one of: 01
)End of group
\/Matches a literal forward slash
\dMatches 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

InputExpected
01/15/2024Match
12/31/2023Match
13/01/2024No Match
1/5/2024No Match
06/30/2024Match

Try It — Interactive Tester

//
gimsuy
No matches found.
Pattern: 51 charsFlags: noneMatches: 0

Ctrl+Shift+C to copy regex

Customize this pattern →