European Date Format (DD/MM/YYYY) in JS
Match European-style dates in DD/MM/YYYY format with valid day (01–31) and month (01–12) ranges.
Try it in the JS tester →Pattern
regexJS
(?:0[1-9]|[12]\d|3[01])\/(?:0[1-9]|1[0-2])\/\d{4} (flags: g)JavaScript / ECMAScript code
jsJavaScript
const re = new RegExp("(?:0[1-9]|[12]\\d|3[01])\\/(?:0[1-9]|1[0-2])\\/\\d{4}", "g");
const input = "15/01/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
Day alternation covers 01–31, month covers 01–12, year is any 4-digit number. Slashes are literal. Does not detect impossible combinations like 31/02/2024.
Examples
Input
15/01/2024Matches
15/01/2024
Input
31/12/1999Matches
31/12/1999
Input
32/01/2024No match
—