Regex Builder
Get a regex with match/reject test cases, a piece-by-piece explanation, ReDoS check, and a straight answer when regex is the wrong tool.
Write a regex for me. What it should match: [DESCRIBE THE PATTERN + PASTE 3-5 REAL STRINGS THAT MUST MATCH] What it must NOT match: [PASTE 3-5 STRINGS THAT LOOK SIMILAR BUT MUST BE REJECTED: this is where most regexes fail] Where it runs: [JAVASCRIPT / PYTHON / GO(RE2) / PCRE / grep: flavors differ on lookbehind, named groups, unicode] The job: [VALIDATE FULL INPUT / EXTRACT PARTS / FIND-AND-REPLACE: changes anchoring and grouping] Deliver: 1. **The regex**: with anchors explicitly decided (^$ for validation, none for search: state which and why), named groups for anything extracted, and the flavor's syntax verified. 2. **Piece-by-piece breakdown**: each component on its own line with what it matches, so I can maintain it in six months. 3. **Test table**: every string I provided plus 5 edge cases you add (empty string, unicode, maximal-length, the almost-valid trap, whitespace variants): | input | expected | why |. Walk the table and confirm the regex agrees. If any row fails, fix the regex before presenting it. 4. **ReDoS check**: state whether the pattern contains catastrophic-backtracking risk (nested quantifiers, overlapping alternations like (a+)+). If it does and my flavor isn't RE2, provide the safe rewrite: user-facing input + backtracking regex is a denial-of-service bug, not a style choice. 5. **The honesty clause**: if this job shouldn't be a regex, say so and show the better tool: a real parser for HTML/JSON/CSV, a date library for dates, a validator library for emails/URLs (the RFC-complete email regex is a famous trap; offer the pragmatic version and state what it deliberately rejects). Rules: match the strings I gave, not the platonic ideal of the format. If my must-match examples conflict with the spec I described, flag the conflict and ask which wins.
How to use
The must-NOT-match examples are the highest-value input: regexes rarely fail on the happy path; they fail by matching too much. The test table makes verification a 30-second read instead of an act of faith, and the ReDoS check matters any time the pattern runs on user input. Paste the table rows into your actual test suite; regexes regress when edited later.
More coding prompts
Write the commit message for this change. Diff: """ [PASTE THE STAGED DIFF] """ Why I made this change: [THE REASON, THE TICKET, THE BUG REPORT, or "you infer it"] Convention: [Conventional Commits / this repo's existing style, pasted below / plain] Recent commits from this repo, to match style: """ [PASTE 5-10 RECENT COMMIT SUBJECT LIN
Commit Message
Write a commit message that explains why the change was made, in Conventional Commits format, split into separate commits when needed.
Help me recover from a git mistake without making it worse. What I was trying to do: [THE GOAL] What I ran: [THE EXACT COMMANDS, IN ORDER] What happened instead: [THE OUTPUT OR THE STATE NOW] Has this been pushed or shared: [YES/NO, and to which branch and whether anyone else has pulled] Uncommitted work I cannot lose: [WHAT AND WHERE, o
Undo a Git Mistake
Recover from a bad commit, force push, wrong branch, or lost work with a reversible plan and the exact commands, explained before you run them.
Handler code, routes, and models: """ [PASTE THE ROUTE DEFINITIONS, HANDLERS, REQUEST AND RESPONSE TYPES, VALIDATION SCHEMAS, AND MIDDLEWARE] """ Generate an OpenAPI 3.1 specification from the code above. API name, version, and base URL: [DETAILS] Auth scheme: [BEARER JWT / API KEY / OAUTH / SESSION COOKIE, and where it is enforced] Con
OpenAPI Spec From Code
Generate an accurate OpenAPI 3.1 spec from handler code, including error responses and auth, with gaps flagged instead of invented.