Regex Generator for Complex Date Formats

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.

The Core Prompt

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.

Technical Value

The "explain each part" instruction is key for learning and ensuring the Regex doesn't have unintended side effects.

Usage Tips

  • Specify Language: Add "for Python" or "for JavaScript" as Regex flavors vary slightly.
  • Edge Cases: Ask the AI to "ensure it doesn't match 31/02/2024" for more advanced logic.

Example AI Output

^(0[1-9]|[12][0-9]|3[01])[- \/.](0[1-9]|1[012])[- \/.](19|20)\d\d$