跳到主要内容
知仓学习社ZHICANG

regex-builder

Build a regular expression from a plain-English description, or explain an existing one. Use when asked to write a regex, match/validate/extract a p…

不碰外部(只输出文字)无严重或高危命中mohitagw15856/pm-claude-skills

它会碰到什么

扫了多少1 个文本文件,3 KB
它会碰到什么不碰外部(只输出文字)
命中总数0 处
命中统计严重 0 · 高 0 · 中 0 · 低 0

这一栏是扫描器报的事实,不是结论。命中多不等于有毒(安全工具、规则库、示例脚本本来就会包含危险写法),命中少也不等于干净。它和你手上的凭据、文件、网络有什么关系,需要你自己看。

技能内容

Regex Builder & Explainer Skill

Produce correct, readable regular expressions — and explain them so the user actually understands what they're shipping.

Working from a brief

Infer the regex flavor (JavaScript/PCRE/Python/Go) from context; if unstated, default to one and say so (assumed — confirm). Always deliver a working pattern and tests even from a loose description. Never leave placeholders.

Required Inputs

  • What should match and what should NOT — 3+ positive examples and, critically, 2+ near-miss negatives (the strings that look matchable but must be rejected). The negatives are where every regex bug lives.
  • The engine/flavor (JavaScript, PCRE, Python re, RE2, grep -E…) — anchors, lookbehind, and Unicode behaviour differ enough to break portability silently.
  • Where it runs — validation, extraction, or replacement changes how greedy the pattern should be.

Two modes

  • Build: the user describes what to match → produce the regex.
  • Explain: the user pastes a regex → break it down.

Detect which from the input.

Output Structure

Pattern

The regex in a code block, plus the flavor and any flags (e.g. i, g, m) and why.

Breakdown

A token-by-token table or list: each part of the pattern and what it matches.

| Token | Matches |

|-------|---------|

| ^ | start of string |

| … | … |

Test cases

  • Matches: 3–5 strings it should match
  • Rejects: 3–5 strings it should not match (include the tricky near-misses)

Notes

Edge cases, catastrophic-backtracking risks, anchoring, Unicode, and a simpler alternative if the regex is getting unwieldy (sometimes "don't use regex" is the right answer — say so).

Quality Checks

  • [ ] The pattern actually passes the listed "matches" and rejects the "rejects"
  • [ ] Flavor and flags are stated
  • [ ] The breakdown covers every token, not just the interesting ones
  • [ ] Edge cases / backtracking risks are flagged

Anti-Patterns

  • [ ] Do not give a regex with no test cases — always prove it
  • [ ] Do not ignore the flavor — \d, lookbehind, and named groups differ across engines
  • [ ] Do not produce an unreadable one-liner when a commented/verbose version or a non-regex approach is clearer
  • [ ] Do not silently assume anchoring — state whether it matches the whole string or a substring

想直接用这个技能?

本站把开放许可(MIT / Apache 等)的技能按仓库打包整理到网盘,点一下转存到你自己的网盘,不用一个个从 GitHub 拉。许可未声明的技能只给原始仓库链接,不打包。

同名技能的其他版本

有 3 个不同仓库或目录里都有叫 regex-builder 的技能。它们内容并不相同,别混用: