$
copilot --idea "Regex Whisperer"
→
Never struggle with regex again — generate, explain, test, and standardise patterns
The Problem
Regular expressions are write-only code. You wrote one 6 months ago that works perfectly. You have no idea how. Now you need to modify it and you're scared to touch it. Meanwhile, every developer on the team has their own email validation regex, and none of them match.
What You'll Build
A regex workflow that lets you:
- Generate complex regex from plain English descriptions
- Explain existing regex patterns in human terms
- Test patterns against edge cases you didn't think of
- Standardise patterns across the codebase
Step-by-Step Walkthrough
Task 1: Generate from Description
$
"Write a regex that matches UK postcodes.
Must handle: standard (SW1A 1AA), BFPO, GIR 0AA, and overseas territories.
Include test cases for valid and invalid inputs.
Explain each part of the regex."
Copilot will generate the pattern AND explain it section by section, something no Stack Overflow answer does reliably.
Task 2: Explain Existing Regex
$
"Explain this regex in plain English, section by section:
^(?=.*[A-Z])(?=.*[a-z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$
Also tell me what it DOESN'T catch that it probably should."
Task 3: Cross-Language Compatibility
$
"I need this regex to work in Python, JavaScript, Go, and Java.
Generate the pattern for each language with the correct syntax and flags.
Note any differences in behaviour between implementations.
Include a test script for each language."
Task 4: Codebase Standardisation
$
"Find every regex pattern in this codebase.
Group them by purpose (email, phone, URL, date, etc.)
For each group, recommend ONE canonical pattern.
Generate a shared regex constants file.
Show me the find-and-replace commands to standardise."
Task 5: Edge Case Discovery
$
"Here's my email validation regex: [pattern]
Generate 20 edge cases that should match and 20 that shouldn't.
Include international domains, plus-addressing,
unusually long addresses, and Unicode characters.
Does my regex handle all of them correctly?"
Pro Tips
• Always ask for test cases alongside the regex — they're more valuable than the pattern itself
• Ask Copilot to use named groups for readability
• For complex patterns, ask for the verbose/extended format with comments
• Don't use regex for HTML parsing — ask Copilot for a proper parser instead
What You'll Learn
• Regular expression syntax and advanced features (lookaheads, named groups)
• Cross-language regex differences
• Testing patterns for correctness and performance
• When to use regex vs when to use a parser