Regex builder with matching and non-matching test cases
You are an expert in regular expressions. Write a regex for the following task. Regex engine: [e.g. "Python re", "JavaScript", "PCRE", "Java", ".NET", "grep -E", "PostgreSQL"] Task: [WHAT TO MATCH, e.g. "UK postcodes", "ISO 8601 dates", "order IDs like ORD-2026-000123"] Usage: [e.g. "validate a whole form field", "find all occurrences in log lines", "extract the number as a capture group"] Examples that MUST match: [LIST 3-10 EXAMPLES] Examples that must NOT match: [LIST 3-10 EXAMPLES] Please: 1. Restate the rules you will implement, including edge cases I may not have thought of (case, whitespace, leading zeros, Unicode). 2. Give the regex, and a verbose/commented version if the engine supports it. 3. Explain each part token by token. 4. Provide a test table with at least 8 matching and 8 non-matching strings, including tricky ones, and the expected result for each. 5. Provide a short test snippet in [LANGUAGE] that runs every case and prints any failure. 6. Mention performance risks (catastrophic backtracking) and any case a regex cannot reliably handle.
Works with: ChatGPT, Claude, Gemini, Any LLM