regex-builder
Skill0 starsChanged 6 months agoMITView on GitHub
Builds, explains, and tests regular expressions, and flags catastrophic-backtracking (ReDoS) risks. Translates plain-English requirements into a correct pattern with a token-by-token explanation and test cases. Use when the user needs a regex, asks what a pattern means, wants to validate/extract/replace text, or mentions regex, pattern matching, or ReDoS.
5 other projects use a version of this.
Adopted by
Most recently taken up by
- mergisi/awesome-openclaw-agentstheir own version, first seen Nov 1, 2026
- poorvith-mp/skills-developertheir own version, first seen Aug 19, 2026
- 0xelitesystem/claude-skills-collectiontheir own version, first seen Jun 11, 2026
- kakarot-oncloud/claude-dev-skillstheir own version, first seen Apr 19, 2026
- jMerta/codex-skillstheir own version, first seen Dec 14, 2025
Other versions5 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 5
- mergisi/awesome-openclaw-agents★ 4.1ksame name
- jMerta/codex-skills★ 130same name
- 0xelitesystem/claude-skills-collection★ 0same name
- kakarot-oncloud/claude-dev-skills★ 0same name
- poorvith-mp/skills-developer★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository11 other files it gives its agents.
- a11y-auditorSkill
- api-design-reviewerSkill
- changelog-writerSkill
- conventional-commit-writerSkill
- dockerfile-hardenerSkill
- env-secrets-auditorSkill
- error-message-explainerSkill
- pr-description-writerSkill
- readme-generatorSkill
- sql-query-optimizerSkill
- test-writerSkill
The file
We split this skill into the rules it gives an agent
3 rules. 0 are common, 2 are distinctive, and 1 is very specific to this project.
0
Common
Most of the 3 edited versions we read keep these.
2
Distinctive
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 45
Prefer RE2-style engines for untrusted input when the feature set allows.
- Very specific: line 49
Default to anchoring (^...$) when validating a full value, and use the smallest character classes that satisfy the spec.
- Distinctive: line 134
Email/URL "validation": no regex fully validates these.
“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Regex Builder
Produce a correct, readable, safe regular expression — and prove it works.
Workflow
- [ ] 1. Restate the requirement: what must match, what must NOT match
- [ ] 2. Confirm the flavor (PCRE/Python/JS/Go/RE2) and flags
- [ ] 3. Build the pattern from anchored, named pieces
- [ ] 4. Explain it token by token
- [ ] 5. Give passing and failing test cases
- [ ] 6. Check for catastrophic backtracking (ReDoS)Step 1 — Pin down the spec
Ambiguity is the main source of wrong regexes. Before writing anything, state explicitly:
- Three to five strings that must match.
- Three to five strings that must NOT match (the near-misses matter most).
- Whether you're matching the whole string (anchor with
^...$) or finding substrings.
Step 2 — Know the flavor
Syntax and capabilities differ. Confirm which engine the regex runs in:
| Engine | Notes |
| JavaScript | \d is Unicode-unaware by default; use u flag; lookbehind in modern engines only |
Python re | Named groups (?P<name>...); re.VERBOSE allows whitespace/comments |
| PCRE / PHP / Java | Richest feature set; supports atomic groups and possessive quantifiers |
| Go / RE2 / Rust | Linear time, no backtracking — no backreferences or lookaround, but ReDoS-immune |
Prefer RE2-style engines for untrusted input when the feature set allows.
Step 3 — Build from named, anchored pieces
Default to anchoring (^...$) when validating a full value, and use the smallest character
classes that satisfy the spec. Build complex patterns from labeled sub-expressions rather
than one dense line.
Reliable building blocks
\d one digit (ASCII) [A-Za-z] one ASCII letter
\w word char [A-Za-z0-9_] \s whitespace
. any char except newline [^...] negated class
a? a* a+ 0-1, 0+, 1+ (greedy) a*? a+? lazy variants
{2,4} between 2 and 4 (?:...) non-capturing group
(?<name>...) named capture group \1 / \k<n> backreference
^ $ \b start, end, word boundary (?i) case-insensitive (inline)
(?=...) (?!...) lookahead / negative lookaheadStep 4 — Always explain the pattern
Break the final regex into a token-by-token table so the user can verify and maintain it.
Step 5 — Provide test cases
List concrete strings that should match and should fail, including tricky near-misses.
Step 6 — ReDoS safety check (do this every time)
Catastrophic backtracking can hang a server on a short malicious input. Flag and fix any pattern where the input can be parsed many ways. The danger signs:
- Nested quantifiers:
(a+)+,(a*)*,(.*)* - Quantified group with overlapping alternation:
(a|a)*,(\d+|\w+)* - Adjacent overlapping quantifiers:
\d+\d+,.*.*
Dangerous: ^(\w+\s?)*$ on "aaaaaaaaaaaaaaaaaaaa!" -> exponential blowup
Safer: ^\w+(?:\s\w+)*$ no overlap between the repeated piecesFixes: remove overlap so each character has one parse path; make a quantifier possessive
(\w++) or wrap in an atomic group ((?>\w+)) in PCRE/Java; or switch to an RE2 engine.
For "match up to a delimiter," prefer a negated class [^"]* over .*?.
Examples
Requirement: validate a US ZIP code (12345 or 12345-6789), full-string.
Pattern (JS/PCRE):
^\d{5}(?:-\d{4})?$Explanation:
| Token | Meaning |
^ | start of string |
\d{5} | exactly five digits |
(?:-\d{4})? | optionally, a hyphen and four more digits (non-capturing) |
$ | end of string |
Tests: match 12345, 12345-6789; reject 1234, 123456, 12345-67, abcde.
Requirement: capture the host from an http(s) URL.
Pattern (Python, re.VERBOSE):
import re
url_re = re.compile(r"""
^https?:// # scheme
(?P<host>[^/:\s]+) # host: up to a slash, colon, or whitespace
(?::\d+)? # optional :port
(?:/\S*)?$ # optional path
""", re.VERBOSE)
m = url_re.match("https://example.com:8080/path")
m.group("host") # -> "example.com"Note the host uses a negated class [^/:\s]+ rather than .+, which keeps it linear-time
and stops at the right boundary.
Common edge cases
- Email/URL "validation": no regex fully validates these; validate format loosely, then verify by sending a confirmation. Don't ship a 200-character email regex.
- Unicode:
\wand\dare ASCII-only in many engines; use\p{L}/\p{N}with the Unicode flag when you need international text. - Multiline:
^/$match line boundaries only with the multiline flag;.excludes newlines unless the dotall/single-line flag is set. - Escaping in code: in most languages backslashes must be doubled in string literals, or
use raw strings (
r"..."in Python, backtick strings in Go).
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.

