{"name":"write-regex-prompt","description":"A prompt that writes a regular expression from a plain-English description for your language, then explains it piece by piece and tests it against strings that should and should not match, flagging slow or risky patterns. Use when the user needs a regex, asks to match emails, phone numbers or URLs, or a regex is not matching.","category":"coding-prompts","tags":["regex","testing"],"models":["any"],"proven":false,"passing_families":0,"model_testing":"Not yet model-tested; testing Jan 2027","url":"https://theskillvault.ai/skills/write-regex-prompt","api_url":"https://theskillvault.ai/api/skills/write-regex-prompt","raw_url":"https://theskillvault.ai/api/skills/write-regex-prompt/raw","body":"# Write a regex (prompt)\n\nRegexes are easy to get almost right. This prompt writes one, explains it and tests it on both kinds of input.\n\n## When to use\n- You need to validate, find or extract text: emails, phone numbers, dates, IDs.\n- A regex you found online does not match what you expect.\n- You want to understand a regex before trusting it.\n\n## Steps\n1. Describe what should match, in plain English, with a few real examples.\n2. Add examples that must not match. These catch most mistakes.\n3. Fill in {{LANGUAGE}} (JavaScript, Python, PCRE, Go and so on) and paste the prompt.\n4. Run its tests in your code or on regex101.com before shipping.\n\n## Prompt\n```text\nWrite a regular expression for {{LANGUAGE}}.\n\nWhat it should match: {{DESCRIPTION}}\nExamples that must match: {{MATCH EXAMPLES}}\nExamples that must not match: {{NON-MATCH EXAMPLES}}\nUse: {{validate a whole field / find inside longer text / extract parts}}\n\nGive me:\n1. The regex, ready to paste, with the flags it needs.\n2. A token-by-token explanation in a short table.\n3. A test table: every example above plus 3-5 tricky ones you add, with match yes/no and any captured groups.\n4. Risks: catastrophic backtracking (nested quantifiers), missing anchors, or cases it cannot handle. If a regex is the wrong tool (for example full email or HTML parsing), say so and suggest a better approach.\n5. A one-line code snippet showing how to use it in {{LANGUAGE}}.\n```\n\n## How to adapt\n- Fixing an existing regex? Replace the description with the regex and say what it gets wrong.\n- Need it readable for a team? Ask for a verbose or commented version.\n\n## Gotchas\n- Regex flavours differ: lookbehind, named groups and Unicode classes vary by language. Always name yours.\n- Badly built regexes can freeze a server on long input (ReDoS). Never run user-supplied patterns, and test on long strings.\n- Do not paste real customer emails or phone numbers as examples; make up similar ones.\n\n## Portability\nWorks with any language and any chat AI. Test on regex101.com or in your own test runner; no tool lock-in.\n\n## Done when\n- The regex passes every must-match and must-not-match example.\n- You understand each part from the explanation table.\n\n## Example prompt\n\"Write a JavaScript regex that matches Australian mobile numbers like 0412 345 678 or +61412345678, but not landlines.\"\n\n---\nBased on the \"RegEx Generator\" prompt by ersinyilmaz on prompts.chat (CC0 1.0, public domain).","files":[],"license":"CC0-1.0","license_name":"CC0 1.0","license_url":"https://creativecommons.org/publicdomain/zero/1.0/","attribution":"Based on work by ersinyilmaz (prompts.chat, 'RegEx Generator') (Public domain (CC0 1.0) - prompt contributed to prompts.chat by ersinyilmaz, CC0 1.0), https://github.com/f/prompts.chat/blob/b09880e229d2f091ffa2254bc187532fb8980f9b/prompts.csv; adapted by TheSkillVault, https://theskillvault.ai","install":{"claude_code":"curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/write-regex-prompt/raw' -o ~/'.claude/skills/write-regex-prompt/SKILL.md'","cursor":"curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/write-regex-prompt/raw' -o '.cursor/skills/write-regex-prompt/SKILL.md'","agents":"curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/write-regex-prompt/raw' -o '.agents/skills/write-regex-prompt/SKILL.md'","mcp_url":"https://theskillvault.ai/mcp","cursor_mcp_deeplink":"cursor://anysphere.cursor-deeplink/mcp/install?name=theskillvault&config=eyJ1cmwiOiJodHRwczovL3RoZXNraWxsdmF1bHQuYWkvbWNwIn0%3D","mcp_config":{"mcpServers":{"theskillvault":{"url":"https://theskillvault.ai/mcp"}}}},"bundles":[],"tested_on":[{"family":"chatgpt","name":"ChatGPT","outcome":null,"date":null,"source":null,"counts":false,"stale":false},{"family":"claude","name":"Claude","outcome":null,"date":null,"source":null,"counts":false,"stale":false},{"family":"gemini","name":"Gemini","outcome":null,"date":null,"source":null,"counts":false,"stale":false},{"family":"grok","name":"Grok","outcome":null,"date":null,"source":null,"counts":false,"stale":false},{"family":"llama","name":"Llama","outcome":null,"date":null,"source":null,"counts":false,"stale":false},{"family":"deepseek","name":"DeepSeek","outcome":null,"date":null,"source":null,"counts":false,"stale":false},{"family":"mistral","name":"Mistral","outcome":null,"date":null,"source":null,"counts":false,"stale":false},{"family":"qwen","name":"Qwen","outcome":null,"date":null,"source":null,"counts":false,"stale":false},{"family":"kimi","name":"Kimi K","outcome":null,"date":null,"source":null,"counts":false,"stale":false}],"proven_rule":{"threshold":5,"window_days":365,"computed_at":"2026-11-02T03:20:33.817Z"}}