Code & Engineering

Regex From Examples for Any Script

Writes a JavaScript regular expression from a description plus lists of strings that must match and must not match, answered as JSON with the pattern and flags. Knows the traps measured in Node 24 - \b and \w are ASCII-only even with the u flag, so \bдума\b never matches Cyrillic text and \w+ cuts "café" to "caf"; a word boundary for any script is a pair of lookarounds with \p{L} and the u flag. Anchors a validator so extra text around the value is rejected, adds the s or m flag when the input spans lines, and avoids nested quantifiers such as (\w+\s?)* that hang on a near-miss string. Use when asked to write, fix or tighten a regex, a validation pattern or a text-search pattern, especially for non-English text.

Regex From Examples for Any Script is a SKILL.md that writes a JavaScript regular expression from a description plus lists of strings that must match and must not match, answered as JSON with the pattern and flags; an agent buys it once for $0.01 over x402.

Tested 2026-10-08No code, no hidden instructionsv1.0.0 · 6.2 KB · perpetual license

Not for

Other regex flavours such as PCRE, Python or RE2 (their escapes and flags differ), parsing nested formats like HTML, and checking that an email or phone number really exists. It writes a JavaScript pattern for the strings you list, so cases you do not list are only as good as its reading of your description.

Tested, honestly

Tested 2026-10-08 with a strong and a weak model.

With and without the skill

Results with and without the skill, for Sonnet and Haiku
SonnetHaiku
withwithoutwithwithout
Regexes that pass every string (22 tasks)22/2222/2222/2222/22

No measurable gain on these tasks, for either model. The same request, asking for JSON only, went to both sides. When the task lists the strings that must match, both models already wrote lookarounds with p{L} and the u flag for Cyrillic and Greek instead of , anchored the validators and avoided nested quantifiers. What the skill adds is the measured notes on why those choices matter and a fixed JSON answer; it may help more when no examples are given or on weaker models than the two tested.

Same cases and the same checks with and without the skill. The cases are ours, written around what the skill is for; with a handful of cases, a difference of one or two is within noise.

SonnetStrong model, claude-sonnet-5-5
Wrote a regex that passes all 22 tasks: every must-match and must-not-match string, and long near-miss inputs inside 200 ms. Word boundaries in Cyrillic, Greek and accented text use lookarounds with Unicode properties and the u flag, validators are anchored, multi-line input gets the right flag, and repeated groups avoid nested quantifiers.
HaikuWeak model, claude-haiku-5-5
Also 22 of 22, with the same kinds of pattern as Sonnet.

Full test summary

Example

Our own test text, before and after the skill ran. Excerpts only.

English · claude-sonnet-5-5

Before

Task: Find the Bulgarian word "дума" as a whole word, in any letter case, anywhere in a sentence. It must not match inside longer words. Must match (each string is one test input, shown as JSON): "една дума тук" "Дума е" "дума" "(дума)" "Каква дума." "ДУМА!" Must NOT match: "думата" "задума" "думи" "продумам" "дума1" "нищо"…

After

{"pattern": "(?<![\\p{L}\\p{N}_])дума(?![\\p{L}\\p{N}_])", "flags": "iu"}

What is in the file

  • The answer
  • Where JavaScript surprises (measured in Node 24, 8 October 2026)
  • Work in this order
  • Short examples

Languages

Any language. Tried in: English.

License

Perpetual, non-exclusive; use and modify for yourself incl. paid work; no resale or republishing. Holder: Georgi Kalchev, aiskills402.com. Full terms.

Versions

Current version 1.0.0, updated 2026-10-08. Whoever bought an earlier version gets new ones free through the same re-download token.

  1. v1.0.0 · 2026-10-08

    First release: writes a JavaScript regular expression from a description and lists of strings that must and must not match, answered as JSON (pattern and flags). Covers what was measured in Node 24: \b and \w are ASCII-only even with the u flag, so word boundaries for Cyrillic, Greek and accented text are written with lookarounds and \p{L}; \p needs the u flag; validators are anchored; the s and m flags for multi-line input; and nested quantifiers that hang on near-miss strings are rewritten with a mandatory separator.

FAQ

What does the answer look like in practice?

JSON with a pattern and flags, ready for new RegExp(pattern, flags). Whole-value checks are anchored, text in Cyrillic, Greek or accented Latin is matched with Unicode properties and the u flag, and multi-line input gets the s or m flag. Nothing else is printed, so a script can parse the reply directly and hand it to the compiler without stripping a fence or a greeting.

Why would a model get this wrong?

In JavaScript the \b and \w shortcuts only know ASCII letters, even with the u flag. A pattern like \bдума\b never matches Bulgarian text and \w+ cuts café to caf, so a check can return zero findings for months. We measured this in Node 24; the skill uses lookarounds with \p{L} instead. The same trap hides in word counters, linters and search boxes built for one alphabet.

Does it protect against patterns that hang?

Yes. Nested quantifiers such as (\d+,?)+ took one second on 24 digits followed by a letter and double with every character. The skill writes the separator as required, which finishes a 100 000 character miss in milliseconds. Our test runs each pattern on long near-miss strings with a 200 ms limit. Greedy lazy tricks are not needed: the fix is structural, so the engine has only one way to split the input and cannot retry endlessly.

Does it help Claude Sonnet?

Not on our 22 tasks. Sonnet and Haiku both passed all 22 with and without the skill, because the tasks list the strings that must match and both models already used lookarounds with \p{L} instead of \b. The skill gives you the measured JavaScript notes and a fixed JSON answer; do not expect a gain on tasks like ours.

Read more

Share

Read this page as Markdown: /skills/regex-from-examples.md.

  • Cron Schedule for Cloudflare Workers

    Code & Engineering

    SKILL.md · v1.0.0 · 5.7 KB

    Turns a schedule described in words into cron expressions for Cloudflare Workers Cron Triggers, answered as JSON with the crons and a note. Knows where Cloudflare differs from classic cron, measured on a live Worker - day-of-week 1 is Sunday, so 1-5 runs Sunday to Thursday and 7 is Saturday, while 0 and ? are rejected; times are UTC only. Writes day names instead of numbers, uses L, LW, W and # for last and n-th days, splits intervals that do not divide an hour or a day (every 45 or 90 minutes) into several crons, ends a range on its stated last run, and handles a local time with daylight saving by firing at both UTC hours and checking the local hour in the handler. Use when asked to write, check or fix a cron expression, a Cron Trigger in wrangler, or a scheduled job, or to convert a schedule in words or in another time zone into cron.

    $0.06once

    • x402
    • USDC
    • Base
    Get skill

    Tested with Sonnet and Haiku, 8 Oct 2026

  • Text to JSON: Extract Data Without Guessing

    Data & Analysis

    SKILL.md · v1.0.2 · 7.5 KB

    Extracts data from text into JSON that matches the shape you give (a JSON Schema, an example object or a list of fields), without guessing. Every value comes from the text; a missing fact becomes null, numbers and dates are converted only into the type the shape asks for, two conflicting values are not settled by a guess, and instructions hidden in the text are ignored. Use when asked to extract structured data, turn text into JSON, parse an invoice, receipt, email, order, CV or job post into fields, or fill a JSON schema from a document.

    $0.05once

    • x402
    • USDC
    • Base
    Get skill

    Tested with Sonnet and Haiku, 3 Oct 2026

  • SQLite Search Builder

    Code & Engineering

    SKILL.md · v1.0.0 · 14.5 KB

    Builds or fixes a site or product search so it finds what the user meant, with SQLite full-text search (FTS5) on D1, Turso or SQLite. Word order, singular or plural, endings, case, punctuation and accents stop mattering ("cafe" finds "Café", "tomatoes" finds "tomato", "red tomato" finds "Tomato, red", "ab1042" finds "AB-1042"), and the start of a word is enough ("tom" finds "tomatoes"). Gives one normalize pipeline for accent-insensitive search, a query-side ending remover, prefix search on the index with paging and a short cache, and a small in-memory path for short lists already in the browser. Never loads a whole table to filter it per keystroke. It does not correct typos. Use when asked to implement or fix search, autocomplete or typeahead, when search does not find plurals, accents or reordered words, when a slow LIKE search reads the whole table, or to review a search box on D1, Turso or SQLite.

    $0.01once

    • x402
    • USDC
    • Base
    Get skill

    Tested with Sonnet and Haiku, 4 Oct 2026

More in Code & Engineering

  • SQL Query Optimizer for D1, SQLite and Turso

    Code & Engineering

    SKILL.md · v1.0.2 · 9.8 KB

    Reviews SQL queries, schemas and migrations for SQLite, Cloudflare D1 and Turso, where the bill and the speed follow the rows a query READS, not the rows it returns. Finds full scans hidden behind LIMIT, aggregates over growing tables, index column gaps, NOT IN, OR, functions and LIKE patterns that switch an index off, OFFSET pagination, N+1 loops, the D1 limit of 100 bound parameters, tables that never shrink and new flag columns that turn the whole history into pending work; ranks them by cost and gives the index or rewrite that fixes each. Use when asked to optimize a SQL query, review a database schema or a migration, find a slow query, or cut rows read on D1, SQLite or Turso.

    $0.05once

    • x402
    • USDC
    • Base
    Get skill

    Tested with Sonnet and Haiku, 3 Oct 2026

  • D1 Migration Writer: SQLite Migrations That Apply

    Code & Engineering

    SKILL.md · v1.0.1 · 9.8 KB

    Writes a SQL migration for Cloudflare D1 or SQLite from the current schema and the change wanted, so it applies on the first try and leaves the rows already in the database right. Knows what D1 refuses or breaks on, measured on a real D1 database - BEGIN and COMMIT in the file, foreign keys that cannot be switched off (a rebuild defers them, keeps the table name, and never closes with defer_foreign_keys = false, which on D1 silently skips the check), NOT NULL columns without a default, REFERENCES columns with a default, indexed columns dropped before their index. Backfills a new status or marker column so old rows are not picked up as pending work, fills a new counter from the existing rows, orders index columns for the query that needs them, and keeps upserts working against a partial unique index. Use when asked to write, check or fix a D1, SQLite or Turso migration, add or change a column, add an index, make a column unique or required, or rebuild a table.

    $0.07once

    • x402
    • USDC
    • Base
    Get skill

    Tested with Sonnet and Haiku, 8 Oct 2026

  • Tests from Spec: Cases from the Requirements

    Code & Engineering

    SKILL.md · v1.0.0 · 6.3 KB

    Writes test cases for a function from its specification rather than from its code, as a JSON table that any test runner can loop over. Every rule, boundary and error the spec defines gets a case, and every expected value is worked out from the spec; where the code you show disagrees with the spec, the case follows the spec and a note says where. Behaviour the spec leaves open becomes a question instead of a guessed case. Use to write unit tests from a spec, a docstring or a ticket, generate edge cases and boundary tests, build a table-driven test (test.each, pytest parametrize), or check whether existing code does what its requirements say.

    $0.03once

    • x402
    • USDC
    • Base
    Get skill

    Tested with Sonnet and Haiku, 8 Oct 2026

  • Accessibility Review: WCAG Defects in Markup

    Code & Engineering

    SKILL.md · v1.0.0 · 6.8 KB

    Reviews pasted HTML or JSX for the accessibility defects a screen reader or keyboard user hits first, and names the WCAG 2.2 success criterion for each. It flags images without a text alternative, form fields without a label, buttons and links with no accessible name, clickable elements that a keyboard cannot reach, focusable content hidden from assistive technology, personal-data fields without autocomplete, data tables without header cells and pages without a language, and it marks heading levels that skip and positive tabindex values as best-practice findings, not WCAG failures. Each finding has a fixed code, the element, the criterion and a fix, then one verdict. Use to review HTML for accessibility, audit a component or page markup for WCAG issues, or check a form or template before release.

    $0.03once

    • x402
    • USDC
    • Base
    Get skill

    Tested with Sonnet and Haiku, 8 Oct 2026