Regex for Date (MM/DD/YYYY)
Validates dates in US format MM/DD/YYYY with basic month and day range checking.
Pattern
/^(0[1-9]|1[0-2])\/(0[1-9]|[12]\d|3[01])\/\d{4}$/ Live Tester
Enter a string to test
Examples
✓ 01/15/2024
✓ 12/31/2023
✓ 06/01/2000
✗ 13/01/2024
✗ 00/15/2024
✗ 1/6/2000
Pattern Breakdown
^(0[1-9]|1[0-2]) — month 01-12
\/ — literal forward slash
(0[1-9]|[12]\d|3[01]) — day 01-31
\/\d{4}$ — slash + four-digit year
Code Snippets
Javascript
const regex = /^(0[1-9]|1[0-2])\/(0[1-9]|[12]\d|3[01])\/\d{4}$/;
regex.test("01/15/2024"); // true Python
import re
pattern = r"^(0[1-9]|1[0-2])/(0[1-9]|[12]\d|3[01])/\d{4}$"
bool(re.match(pattern, "01/15/2024")) # True Php
$pattern = '/^(0[1-9]|1[0-2])\/(0[1-9]|[12]\d|3[01])\/\d{4}$/';
preg_match($pattern, "01/15/2024"); // 1 Related Patterns
Email Address /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/ URL /^https?:\/\/(www\.)?[a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([a-zA-Z0-9()@:%_+.~#?&/=-]*)$/ Phone Number (International) /^\+?[1-9]\d{1,14}$/ Phone Number (US) /^\(?[2-9]\d{2}\)?[-.\s]?\d{3}[-.\s]?\d{4}$/ Phone Number (EU) /^\+?[1-9][0-9]{0,3}[\s.-]?\(?[0-9]{1,5}\)?[\s.-]?[0-9]{1,5}[\s.-]?[0-9]{1,5}$/ IPv4 Address /^((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)$/
Frequently Asked Questions
What is the regex for Date (MM/DD/YYYY)?▾
The regex pattern for Date (MM/DD/YYYY) is /^(0[1-9]|1[0-2])\/(0[1-9]|[12]\d|3[01])\/\d{4}$/. Validates dates in US format MM/DD/YYYY with basic month and day range checking.
How do I use the Date (MM/DD/YYYY) regex in JavaScript?▾
In JavaScript you create the pattern with a regex literal or the RegExp constructor and call .test() to check a string against it. A ready-to-copy example is shown in the Code Snippets section above, alongside Python and PHP versions.
What does the Date (MM/DD/YYYY) pattern match?▾
It matches strings like 01/15/2024; it rejects strings like 13/01/2024. See the Examples section above for the full list of matching and non-matching cases.