agentleFS
Lethe044Lethe044/agentskill-kit/skills/regex-explainer/SKILL.md

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.

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
  1. Distinctive:

    Ask for at least three strings that must match and three that must not, unless they are given.

    line 30
  2. Very specific:

    Start from the simplest pattern that matches the positives, then tighten it with anchors (^, $, \b) until the negatives fail.

    line 31
  3. Very specific:

    Prefer explicit character classes ([0-9], [A-Za-z]) over .

    line 33
  4. Very specific:

    Use non-capturing groups (?:...) when you do not need the text, and named groups when you do.

    line 34
  5. Distinctive:

    Test the pattern against every example and show a table of results.

    line 35
  6. Distinctive:

    Do not use a regex to parse nested or recursive formats (HTML, JSON, source code).

    line 43
  7. Distinctive:

    If the flavor is unknown and the pattern uses flavor specific syntax, say which flavors support it.

    line 54

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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

  1. Name the flavor (Python re, JavaScript, PCRE, POSIX). Behavior differs for lookbehind, named groups and flags.
  2. Split the pattern into tokens: anchors, groups, character classes, quantifiers, alternations.
  3. Explain each token in order, in a short list, then give the whole meaning in one sentence.
  4. Show two strings that match and two that do not, and say why.

Building a pattern

  1. Ask for at least three strings that must match and three that must not, unless they are given.
  2. Start from the simplest pattern that matches the positives, then tighten it with anchors (^, $, \b) until the negatives fail.
  3. Prefer explicit character classes ([0-9], [A-Za-z]) over . and avoid .* in the middle of a pattern.
  4. Use non-capturing groups (?:...) when you do not need the text, and named groups when you do.
  5. 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.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.