US Date Format (MM/DD/YYYY) in JS
Match US-style dates in MM/DD/YYYY format with range validation.
Try it in the JS tester →Pattern
regexJS
(?:0[1-9]|1[0-2])\/(?:0[1-9]|[12]\d|3[01])\/\d{4} (flags: g)JavaScript / ECMAScript code
jsJavaScript
const re = new RegExp("(?:0[1-9]|1[0-2])\\/(?:0[1-9]|[12]\\d|3[01])\\/\\d{4}", "g");
const input = "01/15/2024";
const matches = [...input.matchAll(re)];
console.log(matches.map(m => m[0]));Uses `String.prototype.matchAll` for global iteration (Node 12+ / all modern browsers).
How the pattern works
Month alternation covers 01-12, day covers 01-31, year is any 4-digit number. Slashes are literal separators escaped with \.
Examples
Input
01/15/2024Matches
01/15/2024
Input
12/31/1999Matches
12/31/1999
Input
13/01/2024No match
—