regex-explainer
Skill50 starsChanged 21 days agoMITView on GitHub
Explains regular expressions in plain language, builds new patterns from examples and tests them against matching and non-matching samples. Use when the user pastes a regex they do not understand, needs a pattern for a text format, or wants to find out why a pattern does not match.
In this repository26 other files it gives its agents.
- api-endpoint-testerSkill
- changelog-generatorSkill
- commit-message-writerSkill
- cron-explainerSkill
- csv-profilerSkill
- docker-compose-reviewerSkill
- dockerfile-linterSkill
- env-file-auditorSkill
- git-conflict-resolverSkill
- incident-postmortem-writerSkill
- json-diffSkill
- jwt-inspectorSkill
- log-analyzerSkill
- markdown-link-checkerSkill
- meeting-notes-to-actionsSkill
- openapi-summarizerSkill
- pr-description-writerSkill
- python-code-smellsSkill
- readme-doctorSkill
- release-checklistSkill
- requirements-auditorSkill
- secure-code-reviewSkill
- skill-authorSkill
- sql-query-reviewerSkill
- todo-extractorSkill
- unit-test-writerSkill
The file
We split this skill into the rules it gives an agent
7 rules. About 0 are common, 4 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 30
Ask for at least three strings that must match and three that must not, unless they are given.
- Very specific: line 31
Start from the simplest pattern that matches the positives, then tighten it with anchors (^, $, \b) until the negatives fail.
- Very specific: line 33
Prefer explicit character classes ([0-9], [A-Za-z]) over .
- Very specific: line 34
Use non-capturing groups (?:...) when you do not need the text, and named groups when you do.
- Distinctive: line 35
Test the pattern against every example and show a table of results.
- Distinctive: line 43
Do not use a regex to parse nested or recursive formats (HTML, JSON, source code).
- Distinctive: line 54
If the flavor is unknown and the pattern uses flavor specific syntax, say which flavors support it.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Regex explainer
Regular expressions are dense. Read them in pieces and prove the result with examples.
When to use
- The user pastes a pattern and asks what it does.
- The user describes a format (dates, ids, log lines) and needs a pattern.
- A pattern matches too much, too little, or is very slow.
Explaining a pattern
- Name the flavor (Python
re, JavaScript, PCRE, POSIX). Behavior differs for lookbehind, named groups and flags. - Split the pattern into tokens: anchors, groups, character classes, quantifiers, alternations.
- Explain each token in order, in a short list, then give the whole meaning in one sentence.
- Show two strings that match and two that do not, and say why.
Building a pattern
- Ask for at least three strings that must match and three that must not, unless they are given.
- Start from the simplest pattern that matches the positives, then tighten it with anchors (
^,$,\b) until the negatives fail. - Prefer explicit character classes (
[0-9],[A-Za-z]) over.and avoid.*in the middle of a pattern. - Use non-capturing groups
(?:...)when you do not need the text, and named groups when you do. - Test the pattern against every example and show a table of results. If a code runner is available, run it.
Common problems
- Greedy quantifiers swallow too much. Use a lazy quantifier (
.*?) or a negated class ([^"]*). - Missing anchors make a pattern match inside longer text. Add
^...$or\b. - Unescaped special characters (
.,?,+,() inside literal text. - Nested quantifiers such as
(a+)+can take exponential time on long input. Rewrite them. - Do not use a regex to parse nested or recursive formats (HTML, JSON, source code). Use a parser.
Example
Pattern: ^(\d{4})-(\d{2})-(\d{2})$
Matches a date like 2024-05-17 and captures year, month and day. It rejects 2024-5-17 (month has one digit)
and x2024-05-17 (anchored). It does not check that the month is 1 to 12.
Errors
If the flavor is unknown and the pattern uses flavor specific syntax, say which flavors support it.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

