Regex builder with test table, ReDoS check and flavour caveats

by fidji DeepSeek English ~643 tokens
Public excerpt Locked
Flavour first (PCRE, JavaScript, Python, Go RE2, .NET), full-string validation or extraction? Build the pattern token by token, run every positive and negative example through it, add edge cases, check nested quantifiers for ReDoS…

About this prompt

Describe what to match and give examples that must and must not match: the prompt builds the pattern piece by piece, verifies it against every example in a test table, adds the edge cases you forgot, checks for catastrophic backtracking and flavour differences, and says when a regex is the wrong tool. DeepSeek’s step-by-step reasoning suits this kind of verification.

Example output

Provided by the author
STEP 1 — Choices: spaces, dots or nothing between pairs (not mixed); ASCII digits only; whole-string validation. STEP 3 ``` ^(?:\+33\s?|0)(?<lead>[67])(?:[\s.]?\d{2}){4}$ ``` STEP 4 — Tests (excerpt) | Input | Expected | Result | Decided by | | 06 12 34 56 78 | match | match | `0` then `[67]` then 4 × `\s?\d{2}` | | +33 7 12 34 56 78 | match | match | `\+33\s?` | | 0612 34 56 78 | match | match | separators optional per pair (accepted, see note) | | 05 12 34 56 78 | no | no | `[67]` fails on 5 | | "06 12 34 56 78\n" | no | MATCH in PHP | `$` accepts a final newline → use `\z` | Fix: replace `$` with `\z` (PCRE). Re-run: all 14 rows pass. STEP 5 — No nested quantifiers: linear time, safe on untrusted input. Note: `[\s.]?` allows "06.12 34.56 78" (mixed). Strict version with one separator captured and reused: `(?<sep>[\s.]?)…\k<sep>`…

Details

Model
DeepSeek
Prompt language
English
Who it's for
Developers, data analysts and sysadmins who need a regular expression they can trust in production
Length
~643 tokens (estimate)
Delivered as
Prompt text, shown online after purchase

Reviews

Buyers only

No reviews yet. Only buyers of this prompt can leave one.

Report this prompt