Regex test cases: verify a pattern with a match table and ReDoS checks

Run a regex against should-match and should-not-match cases, show captured groups, and flag catastrophic-backtracking patterns with a timed stress test.

ClaudeHermes AgentCodexCursorMIT (modify, redistribute and use commercially)Python

What it does

A procedure for never handing over an untested regex.

  • Loads a case table in text form (+ must match / - must not match) or JSON and runs the pattern with Python re
  • Prints PASS/FAIL, the match, span, and numbered and named groups for each case; JSON cases can also assert expected groups
  • Statically flags catastrophic-backtracking (ReDoS) constructs such as nested quantifiers like (a+)+ or (\w+\s?)+ and repeated overlapping alternatives
  • Runs every case in a worker process with a timeout so a runaway pattern cannot hang, and --stress times risky fragments on growing input
  • Includes checks for common traps such as $ matching before a trailing newline and \d matching full-width digits

How to use

python scripts/regex_test.py examples/postal.txt
python scripts/regex_test.py examples/email.json --stress
python scripts/regex_test.py --pattern "(a+)+$" --lint-only

Ask Claude, Codex, Hermes Agent or Cursor to write or fix a regex; it writes the test table first, iterates until every case passes, and delivers the pattern with the results.

Requirements

  • Python 3.10+ (standard library only; atomic groups and possessive quantifiers need 3.11+)

Caveats

  • Tests run on Python re. Other engines such as JavaScript or Go differ in syntax and behavior; porting notes are part of the procedure.
  • The backtracking lint is heuristic. A clean result is not proof of safety, so keep long non-matching cases in the table.
  • It only reads the case file; nothing is modified or sent over the network.

How to install

  1. Unzip the downloaded file (it contains a regex-test-cases/ folder with SKILL.md).
  2. Copy the whole folder into your agent's skills folder.
    • Claude: ~/.claude/skills/ (per project: .claude/skills/)
    • Hermes Agent: ~/.hermes/skills/
    • Codex: ~/.agents/skills/ / Cursor: ~/.cursor/skills/
    • Claude app (claude.ai): upload the ZIP in Customize → Skills
  3. Restart the agent and check that the skill appears in its skill list.

Step-by-step install for Windows / Mac and each agent

Seller

AI Skill Market (official)

44 published skills

Seller profile and all skills