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 tested 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.
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 |
| with | without | with | without |
|---|
| Regexes that pass every string (22 tasks) |
| Regexes that pass every string (22 tasks) | 22/22 | 22/22 | 22/22 | 22/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.
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.