Regex explain
Explain a regular expression piece by piece, with examples that match, examples that do not, and the cases where it will surprise you.
The prompt
Explain this regular expression. Pattern: PASTE IT Flavour or language, if I know it: WHICH. What it is supposed to match: WHAT. Five parts. One sentence. What it matches overall. Piece by piece. A table: the fragment, what it does, and what it would match on its own. Include anchors, groups, escapes and every quantifier. Matches. Five example strings it accepts, chosen to include at least one that is surprising. Does not match. Five example strings it rejects, chosen to include the near misses people expect it to accept. This is the useful half. Surprises. Where it will not behave as the author intended. Look specifically at: a dot matching more than expected, a greedy quantifier running past its intended stop, a missing anchor allowing a partial match anywhere in the string, a character class that quietly includes something, and any construct that could backtrack badly on a long input. Then one line on flavour. Whether the pattern behaves differently in another common flavour, and which construct causes the difference. You cannot execute anything here, so derive every example from the pattern and say if one is uncertain. Then tell me which of the examples I should actually run to confirm.
How to use it
Run this in Chat. It is a thinking tool, not a deliverable.
Use when you are about to trust a pattern somebody else wrote, or one you wrote a month ago.
Vibe prepares and drafts. You verify and decide. Ask for a citation on every finding: a confident answer is not evidence.
What you get back
A piece by piece reading, matching and non-matching examples, the surprises, and flavour differences.
What it writes
Nothing. This one only answers.
From the source file in awesome-mistral-vibe-prompts, CC BY-SA 4.0. Not affiliated with, or endorsed by, Mistral AI.