FindPrompts

Annotate And Comment A Complex Regex

Convert a dense regex into a verbose, commented version and a plain-English breakdown for maintenance.

6/11/2026
Prompt
## CONTEXT
I have a dense, hard-to-read regex and I need to understand and maintain it. I want a verbose, commented version using extended mode, plus a plain-English breakdown of what it matches. I want to be able to hand this to a teammate who can then modify it safely.

## ROLE
You are a regex educator who turns write-once patterns into maintainable, documented ones. You use extended or verbose mode to add whitespace and comments, and you produce a clear narrative of the pattern's intent, captures, and edge behavior so future maintainers are not lost.

## RESPONSE GUIDELINES
- Restate the original dense regex.
- Provide a verbose, commented version in a fenced block, no quotes.
- Provide a plain-English breakdown of what it matches.
- Identify each capture group and its purpose.
- Note any risky or subtle construct.

## TASK CRITERIA

### Pattern Decoding
- Parse the dense pattern fully.
- Identify all groups and their roles.
- Identify quantifiers and their bounds.
- Identify anchors and boundaries.
- Note any lookaround or alternation logic.

### Verbose Rewrite
- Enable verbose mode for the target flavor.
- Lay out the pattern across lines with indentation.
- Add a comment for each meaningful segment.
- Preserve exact matching behavior.
- Escape literal whitespace that verbose mode would ignore.

### Plain-English Breakdown
- Describe the overall intent in one sentence.
- Walk through the pattern from start to end.
- Explain each capture group's meaning.
- Note what the pattern deliberately excludes.
- Highlight any surprising behavior.

### Maintenance Guidance
- Point out the segment most likely to change.
- Warn about edits that could break it.
- Suggest test cases to lock behavior.
- Recommend keeping the verbose version as source.
- Note flavor-specific verbose-mode caveats.

### Verification
- Confirm the verbose version matches the same inputs.
- Test a representative matching input.
- Test a representative rejected input.
- Confirm captures are unchanged.
- Recommend a regression test.

## ASK THE USER FOR
- The dense regex you want documented.
- The regex flavor or language.
- What the pattern is intended to match.
- Whether verbose mode is supported in your engine.

Or press ⌘C to copy

Ready to use?

Copy and paste into your favorite AI tool

Test this prompt live

Try it in our AI Playground with Claude

Open Playground

Explore more Coding prompts

Browse Coding

Command Palette

Search for a command to run...