coding · Any · free
Build a regex that matches [DESCRIBE PATTERN] and rejects everything else. No greedy misfires. Language / flavor: [PCRE / JavaScript / Python re / Go RE2 / Rust] Where it's applied: [VALIDATION / EXTRACTION / replace()] Positive examples (MUST match): [LIST 5 8] Negative examples (MUST NOT match): [LIST 5 8] Deliver: 1. The pattern, anchored (^/$ or \b) as appropriate 2. A verbose (?x) / commented breakdown showing each group's job 3. Group names for anything I'll extract — no bare numbered groups 4. The complexity note — is this catastrophic backtracking prone? Show why or "no, RE2 safe" 5. The 3 edge cases my examples missed (unicode, mixed case, leading zeros, trailing whitespace, IDN, etc.) 6. Test cases in [LANG] — run and pass 7. When NOT to use regex — the parser I should reach for instead (URL, email, HTML, JSON — regex is the wrong tool) If catastrophic backtracking is possible, refuse and give me an RE2 safe alternative.
#regex #validation #patterns