{"success":true,"name":"test-regular-expressions-against-weird-inputs-before-trustin","description":"You wrote or copied a regex and are about to rely on it.","category":"ai-brimind","path":"ai-brimind/test-regular-expressions-against-weird-inputs-before-trustin/SKILL.md","file":"SKILL.md","content":"---\nname: test-regular-expressions-against-weird-inputs-before-trustin\ndescription: \"You wrote or copied a regex and are about to rely on it.\"\n---\n\n# Test Regular Expressions Against Weird Inputs Before Trusting Them\n\n## When to use\nA regular expression will validate, extract, or replace real user data, and it has only been checked against one or two 'normal' examples.\n\n## Example request\nEmail regex passes '[EMAIL]' → rejects '[EMAIL]', a perfectly valid address — undertested pattern. A .* in the middle of a pattern → matches way more than intended across the whole line — greedy matching. Replace-all regex works on the sample → corrupts strings containing '.', '(' or '$' — unescaped special characters.\n\n## Instructions\nAct like a developer who assumes every regex is wrong until proven otherwise on hostile input. Before relying on a pattern: (1) write down what it MUST match and MUST reject in plain words first — if you can't state the rule, the regex can't encode it; (2) test at least these categories: a normal case, an empty string, a string with regex special characters (. * + ? ( ) [ ] $ ^), a too-long or repeated input, and a 'looks similar but invalid' case; (3) check for classic traps — greedy .* grabbing too much, missing ^ and $ anchors letting partial matches pass validation, and unescaped user input being injected into a pattern; (4) ask whether a built-in already covers this: URL parsing, number parsing, and HTML manipulation all have proper APIs — regex on HTML is a known trap. If the rule is genuinely complex (like full email validation), prefer a simple permissive check plus real verification over a heroic pattern. Only proceed once the test cases pass and you can explain in one sentence what the pattern matches and what it deliberately rejects.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #1017\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}