BestPromptFinder
Write and Explain a Regex With Test Cases
85AI Quality /100
91AI Usefulness est. /100
76Eval Confidence /100
No votes yetCommunity results
The prompt
Write a regular expression for me and prove it works. What it should match: [e.g. Indian mobile numbers with or without +91 / PAN format / dates like 17-10-2026 / email addresses in a log line] What it must NOT match: [examples] Where I'll use it: [Python / JavaScript / Java / grep / a form validator / Excel or Google Sheets] Whole-string match or find inside text: [ ] Give me: 1. The regex, written for my language's flavour. 2. A piece-by-piece explanation in a table: part | meaning. 3. Ten test strings: six that should match and four that shouldn't, including tricky edge cases, with the expected result for each. 4. A tiny code snippet that runs those tests in my language. 5. Limits: what the pattern deliberately doesn't check (e.g. it validates format, not whether the number exists). Rules: prefer a readable pattern over a clever one; avoid patterns that can backtrack badly on long input; if my examples conflict, point that out first.Find similar in the app →
Did this prompt work for you?
Why this prompt
- Hand-picked, editorially reviewed prompt
- Written for ChatGPT, Claude, Gemini
Source
Created by BestPromptFinder — editorial prompt, not user-generated. See our content & source policy.
Related Coding prompts
Python: Download a CSV From a URLQuality 94 · GPT-5.6Public-Market and Competitor Data Collection Agent
Quality 92 · GPT-5.6Plain-English to SQL Query Writer
Quality 91 · GPT-5.6PRD to MVP Technical Plan
Quality 90 · Claude CodeThird-Party API Integration
Quality 90 · Claude CodeDatabase Schema and Migration
Quality 90 · Claude Code