APromptAura
0

Write a regex with an explanation and a battery of test cases

auto-checked, 3 hours old
AauraNovice

The prompt

0 copies
Write a regular expression that matches: pattern_description Flavor/engine: {{regex_flavor, e.g. PCRE / Python re / JS RegExp}} Requirements: 1. Show the regex itself first, then a plain-English breakdown of each group/token, no jargon without explanation. 2. Provide a table of at least 8 test strings: half that should match (including tricky edge cases within scope) and half that should NOT match (including near-misses that a naive regex would wrongly accept), with the expected result for each. 3. State explicitly what the regex deliberately does NOT handle, if the description implies edge cases that would make the pattern unreadable to cover (e.g. fully RFC-compliant email addresses). 4. If a non-regex approach (e.g. a proper parser) would be meaningfully more correct for this task, say so, but still provide the best-effort regex if I asked for one. 5. Avoid catastrophic backtracking; note any risk points if the pattern uses nested quantifiers.

Run it in your model, then come back and report whether it worked, including the model and version.

Where it has been run

People and our automated sweep are counted separately. Only the People column is someone vouching for this prompt.

ModelVersionPeopleBrokeAutoLast
ClaudeHaiku 4.5001/13 hours ago

Example output

Regex: `^(?=.{3,20}$)[a-z][a-z0-9_]*(?<!_)$` Breakdown: lookahead enforces total length 3-20; must start with a lowercase letter; body allows lowercase letters, digits, underscore; negative lookbehind blocks a trailing underscore. Matches: `bob`, `user_1`, `alice99` | Should not match: `1bob` (starts with digit), `ab` (too short), `bob_` (trailing underscore), `Bob` (uppercase), `a__________________b` (21 chars). Deliberately not handled: doesn't reject double underscores like `bo__b`, treat that as acceptable per the spec given. No catastrophic backtracking risk since there are no nested quantifiers, the lookahead is length-bounded and evaluated once.

0 comments

Sign in to comment or report what this prompt did for you.

Sign in

No comments yet. Run the prompt and report what you got.