Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIMuseMuseDotsDots+21 more

    Regex Builder Explainer and Tester with ReDoS Check

    1

    Build, explain and test regular expressions for your exact flavor, run real pass/fail tests, catch ReDoS, get paste-ready code. Verdict SAFE / RISKY / REWRITE.

    $5

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned
    Regex Builder Explainer and Tester with ReDoS Check

    Regex Builder Explainer and Tester with ReDoS Check

    Example session with this skill installed

    Our Node API validates usernames with /^([a-zA-Z0-9]+[._-]?)+$/ and a security scan flagged it as ReDoS. Usernames are 3-20 chars, letters and digits, with a single . _ or - allowed only between alphanumerics. Fix it, and give me the same rule for our Go service.

    • Read your context and instructions
    • Compiled the regex builder explainer

    Regex: username validation · Flavor: JavaScript (Node 22) + Go RE2 · Verdict: REWRITE

    Spec: 3-20 chars, ASCII letters/digits, single . _ or - only between alphanumerics · Mode: full-string · Examples: user-supplied + generated

    Why REWRITE

    ^([a-zA-Z0-9]+[._-]?)+$ nests a + inside a + with an optional separator, so aaaa can be split many ways. Measured in Node 22 on "a"*n + "!":

    ntime
    207.46 ms
    24128.04 ms
    282156.71 ms (stopped)

    It also has no length limit.

    Pattern (JS)

    ^(?=.{3,20}$)[a-zA-Z0-9]+(?:[._-][a-zA-Z0-9]+)*$

    TokenMeaning
    (?=.{3,20}$)lookahead: total length 3-20
    [a-zA-Z0-9]+starts with 1+ alphanumerics
    (?:[._-][a-zA-Z0-9]+)*each separator must be followed by alphanumerics
    $end of string

    Every character now has exactly one path, so there is no blowup: same input at n=28 ran in 0.00 ms.

    Tests (Node 22, rxtest.mjs)

    InputExpectResult
    sam, data_owner, a.b-c_d, user2026, 20-char namematchPASS x5
    ab, .sam, sam., a..b, a._b, 21-char name, sam doe, sam!no matchPASS x8

    13/13 passed

    Paste-ready code

    const USERNAME = /^(?=.{3,20}$)[a-zA-Z0-9]+(?:[._-][a-zA-Z0-9]+)*$/;
    export const validUsername = (s) => USERNAME.test(s);
    

    Go's RE2 rejects (?= (tested: "invalid or unsupported Perl syntax"), so the length check moves into code:

    var usernameRe = regexp.MustCompile(`^[a-zA-Z0-9]+(?:[._-][a-zA-Z0-9]+)*$`)
    
    func validUsername(s string) bool {
    	return len(s) >= 3 && len(s) <= 20 && usernameRe.MatchString(s)
    }
    

    Go run: same 13 cases, 13/13 passed. RE2 is linear-time, so no ReDoS check needed there.

    Notes

    • ASCII only by design; non-ASCII names fail in both versions.
    • Go len counts bytes, which equals characters here because the pattern only allows ASCII.

    Connects securely to your tools. The creator never sees your data.

    About this skill

    Regex answers from a chat window often look right and fail in production: lookbehind that Go rejects, \d that means something different in Python and JavaScript, a pattern that never got tested against the strings that should NOT match, or a nested quantifier that hangs your API on a 30-character input.

    This skill gives your coding agent a fixed routine for regular expressions:

    • Asks once for flavor, examples and mode, then proceeds with stated defaults
    • Checks the target flavor first (JavaScript, Python re, PCRE/PHP, Java, .NET, Go RE2, Rust regex, POSIX grep/sed/awk, ripgrep) using a reference matrix of lookaround, backreference, named-group and Unicode differences
    • Explains any pattern token by token in a table
    • Runs a must-match / must-not-match test table in the shell with included Python and Node harnesses, and reports only results it actually ran
    • Scans for catastrophic backtracking shapes and measures suspect patterns with a bounded timing loop, then offers a safe rewrite
    • Outputs paste-ready code with correct escaping for the host language (raw strings, JS literals, Java and JSON double escaping, PHP delimiters, shell quoting)
    • Warns when regex is the wrong tool (HTML, nested structures, full email RFC validation) and names the right one
    • Ends with a SAFE, RISKY or REWRITE verdict

    Who it's for: developers writing input validation, log searches, data cleaning or config rules, and anyone porting a pattern between languages or responding to a ReDoS finding.

    Honesty note: the skill tells the agent never to report a pass, a fail or a timing it did not run. Flavor facts in the reference file were checked against official docs in October 2026, with sources listed; engines change, so rows that may shift are marked for re-checking.

    Test results depend on the regex engines installed in your shell; when the exact runtime is missing, the agent tests in the closest engine and says which. ReDoS timing is a measured check, not a formal guarantee. Flavor facts were verified in October 2026 and may change with new engine versions. It does not replace a parser for HTML, JSON or other nested formats.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before any payment.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    Money-back guarantee

    Doesn't do what its page promises? You get your money back.

    Trust & safety

    Security scan

    Security scan passed 1 month ago

    Permissions

    Read Files
    Write Files
    Network Access
    Listed1 month ago

    What's inside

    Frequently Asked Questions

    A SKILL.md with the step-by-step routine, test harness scripts for Python and Node, a ReDoS timing loop, the verdict rules and output template, plus references/regex-flavors.md with the flavor matrix, anchor rules, ReDoS shapes and rewrites, escaping table, wrong-tool table and source links.

    Any agent that loads SKILL.md skills, such as Claude Code, Codex CLI, Cursor, VS Code Copilot and Gemini CLI. Running the tests needs shell access with python3 or node; Go, grep and ripgrep are used if installed.

    Unzip the regex-builder-explainer folder into your agent's skills directory (for Claude Code, ~/.claude/skills/ or .claude/skills/ in a project). Then ask for a regex, paste one to explain, or mention a ReDoS finding.

    Tests run in the engines available in your shell. For PCRE, Java or .NET without that runtime installed, the agent tests in the closest engine and says so, and results can differ. Timing checks show exponential behavior on your machine; they are not a formal proof of safety.

    It forces a flavor check before writing, a real test run with must-not-match cases, a measured ReDoS check, correct escaping for your language and a clear verdict, instead of an untested pattern that may use syntax your engine rejects.

    While it excels at complex string validation and pattern matching, it is not designed for parsing recursive or nested structures like HTML, XML, or JSON, which require a full parser rather than regex.

    New in Code Quality & Review