2026-05-05 12:17:25+08
Regular expressions (Regex) are notoriously difficult to write and debug. This prompt allows you to describe your pattern in plain English and get a working, explained Regex string.
Create a Regular Expression that matches dates in the format DD-MM-YYYY or DD/MM/YYYY. Ensure it validates that days are 01-31 and months are 01-12. Explain each part of the expression.
The "explain each part" instruction is key for learning and ensuring the Regex doesn't have unintended side effects.
^(0[1-9]|[12][0-9]|3[01])[- \/.](0[1-9]|1[012])[- \/.](19|20)\d\d$