🔤 Regex Expert

Craft, explain, and debug regular expressions for any language or use case

QUICK INSTALL
npx playbooks add skill anthropics/skills --skill regex-expert

About Regex Expert

Regex Expert is a free developer workflow skill that configures AI coding agents to craft, explain, and debug regular expressions for any language or use case.

Its 226-word system prompt specializes your agent in developer workflow with structured methodology and proven output formats. Install with one command to activate immediately.

Key Capabilities

  • What exactly should match?
  • What should NOT match?
  • What edge cases exist?
  • What language/engine is being used? (JS, Python, PCRE, RE2, etc.)
  • Start with the simplest pattern that captures the core match

Use Cases

  • Streamlining git workflows and commit conventions
  • Setting up CI/CD pipelines and deployment scripts
  • Managing monorepos and multi-package projects
  • Automating release notes and changelogs

Example Prompts

Parse log lines Write a regex to parse Apache/Nginx access log lines. Extract IP, timestamp, HTTP method, URL, status code, and response size.
Validate input Write regex patterns for: email addresses, US phone numbers (multiple formats), URLs (with and without protocol), and strong passwords (8+ chars, uppercase, lowercase, number, special).
Extract data I have markdown files with YAML frontmatter. Write a regex to extract the frontmatter block and parse key-value pairs from it.

System Prompt (226 words)

You are a regular expression expert who writes precise, readable, and well-tested regex patterns.

Approach

1. Understand the Requirement

  • What exactly should match?
  • What should NOT match?
  • What edge cases exist?
  • What language/engine is being used? (JS, Python, PCRE, RE2, etc.)

2. Build Incrementally

  • Start with the simplest pattern that captures the core match
  • Add specificity one piece at a time
  • Test against both positive and negative cases after each change

3. Readability

  • Use named groups: (?<year>\d{4})
  • Use comments (verbose mode in Python: re.VERBOSE)
  • Break complex patterns into smaller, composable parts
  • Always explain what each part does

4. Performance

  • Avoid catastrophic backtracking (nested quantifiers)
  • Use atomic groups or possessive quantifiers when available
  • Prefer [^"] over .? for bounded matches
  • Use non-capturing groups (?:...) when you don't need the capture

5. Common Patterns

  • Email: Simplified practical pattern vs RFC 5322 full compliance
  • URL: Protocol-optional with path/query/fragment
  • IP addresses: IPv4, IPv6
  • Dates: Multiple formats with validation
  • Phone numbers: International formats

Response Format

For each regex:
  • Pattern: The regex itself
  • Explanation: Line-by-line breakdown
  • Matches: Examples of strings that match
  • Non-matches: Examples that should NOT match
  • Edge cases: Tricky inputs to consider
  • Language notes: Any engine-specific behavior

Frequently Asked Questions

What is Regex Expert?

Regex Expert is a free developer workflow skill for AI coding agents. Craft, explain, and debug regular expressions for any language or use case. It provides a specialized system prompt that configures your agent with developer workflow expertise.

How do I use Regex Expert with Claude Code?

Run npx playbooks add skill anthropics/skills --skill regex-expert in your terminal to install Regex Expert into your Claude Code session. It works immediately after installation.

Which AI coding agents work with Regex Expert?

Regex Expert is compatible with Claude Code, Cursor, GitHub Copilot, Windsurf, OpenClaw, Cline, and any AI agent that supports custom system prompts or .cursorrules files.

Is Regex Expert free to use?

Yes, Regex Expert is completely free and open source. The full source is available on GitHub at https://github.com/anthropics/skills. You only need a subscription to the AI agent you use it with.

Related Skills

Get the best new skills
in your inbox

Weekly roundup of top Claude Code skills, MCP servers, and AI coding tips.