Say only
what it can mean.
Use short rules. Errors show a line and column. Quoted text stays literal.
START HERE
A complete rule
start "ABC"
3 digits
end/^ABC\d{3}$/uMatches ABC123
Rejects ABC12, ABC1234
Use line start and line end for line-based matching. Unscoped line anchors add JavaScript's m flag. Input and line anchors can be mixed: start with line end checks the beginning of the input and the end of a line; line start with end checks the beginning of a line and the end of the input. A single anchor can also be used alone.
start and end always match the true input edges, including with m. They reject a final line break outside the pattern. line start and line end use native multiline boundaries.
🏗️ Put the atoms together: four complex examples with complete explanations ↗ cover access logs, telemetry, artifact manifests and multiline documents. The Markdown guide is included for offline reading.
BUILDING BLOCKS
Match one thing
| Instruction | Source | Meaning |
|---|---|---|
any character | . | One character, except a line break unless s is on |
any text | .* | Longest text up to the next rule. s includes line breaks. |
word / not word | \w / \W | ASCII letters, digits, underscore / everything else |
word character / word characters | \w / \w+ | One / one or more ASCII letters, digits or underscores; counts replace the plural default |
digit / not digit | \d / \D | ASCII digit / anything else |
letter | [A-Za-z] | One ASCII letter; excludes digits and underscores |
letters | [A-Za-z]+ | One or more ASCII letters |
hex digit | [0-9A-Fa-f] | One ASCII hexadecimal digit, in either letter case |
hex digits | [0-9A-Fa-f]+ | One or more hexadecimal digits; no prefix or separators |
space / not space | \s / \S | JavaScript whitespace / anything else |
path segment character(s) | [^\/\\\u{0}\u{a}\u{d}\u{2028}\u{2029}] / same class with + | Unicode characters excluding slash, backslash, NUL and line breaks |
spaces | \s+ | One or more JavaScript whitespace characters, including tabs and line breaks |
digits | \d+ | One or more digits |
"ABC" | ABC | Exact quoted text; regex punctuation is escaped |
one of: a, b | [ab] | One listed character |
none of: a, b | [^ab] | One character outside the list |
space matches one whitespace character; spaces matches one or more, including tabs, nonbreaking spaces and line breaks. Counts replace that default: 3 spaces is exactly three whitespace characters, and between 0 and 2 spaces permits empty input. Use 3 " " for three ordinary spaces only. Write counts before the item; spaces 3 times and not spaces are unsupported.
between 1 and 32 path segment characters gives a component length without a long escape list. Spaces, Unicode and dots are allowed; reserved names, path traversal and other filesystem rules need separate checks.
letter and letters are not Unicode alphabetic classes: they exclude é by default. With i, JavaScript case folding also matches equivalents such as K and ſ; the explanation reports this. Use 3 letters or a range to limit the count.
text without: a, b matches zero or more characters outside that list. Add start and end to check the whole string. Quote punctuation and spaces in lists, for example one of: "]", "-", " ". Each item must be one Unicode code point. A literal can contain multiple characters. A trailing list comma is an error; Go to error selects that comma so you can remove it.
Use straight JSON double quotes, such as "A". Single quotes, backticks and smart quotes are not string delimiters; unsupported quoted literals and list entries offer a repair hint. Quote characters remain valid matching data inside JSON strings or as individual list items.
An empty literal "" is an error. To match only empty input, put start and end on separate lines; they produce ^$.
Unicode direction controls and C1 control characters appear as visible escapes such as \u202e and \u009b in regexes and explanations. Line separators are also displayed as escapes. Matching still uses the original values. Ordinary Arabic and Hebrew letters and emoji stay unchanged.
Lone UTF-16 surrogates are literal data, escaped for copying. Matching uses Unicode code points: joining a trailing high surrogate to a leading low surrogate forms a new astral character. A repeated literal such as 2 "\udc00A\ud800" therefore does not match that string's JavaScript .repeat(2) value.
HOW MANY
Repeat one thing
Lazy matching: prefix a repeated item with lazy to try its minimum count first, expanding if following rules require more. lazy digits produces \d+?; lazy any text produces .*?. This also works with explicit counts, optional items, groups, captures, choices and references. Exact counts stay fixed. Greedy matching remains the default. Included in npm 0.1.0-dev.5.
Put a repetition modifier before one item: 3 digits generates \d{3}, and between 2 and 4 digits generates \d{2,4}. optional "-" is the same as between 0 and 1 "-". Use zero or more digit, one or more digit or at least 3 digit for repetition without an upper limit. digits, hex digits, letters and spaces mean one or more unless a modifier replaces that default. any text and text without already match sequences.
To set their length, use countable items: 3 any character or between 2 and 4 none of: a, b. Counted sequence errors suggest these replacements. any character excludes line breaks unless s is enabled; none of: excludes only the listed characters.
| Form | Source | Count |
|---|---|---|
3 <item> (for example, 3 digits) | {3} | Exactly three |
between 2 and 4 <item> | {2,4} | Two, three or four; both bounds included |
optional <item> | {0,1} | Zero or one |
zero or more <item> | * | Zero or more, with no upper limit |
one or more <item> | + | One or more, with no upper limit |
at least 3 <item> | {3,} | Three or more, with no upper limit |
Numeric counts must be integers from 0 to 1,000, including the minimum in at least. In a range, the upper count must be at least the lower. between 0 and 1 "-" and optional "-" allow zero or one hyphen. A multi-character literal stays together: between 2 and 4 "AB" generates (?:AB){2,4}.
Write counts with digits 0–9; leading zeros are allowed. A sign, fraction, scientific notation or localized digit produces a count error. Every modifier needs an item: use 3 digits, rather than 3 alone. at least also needs a minimum count. Incomplete modifiers report their position and offer a complete example, such as at least 3 digits or zero or more digit.
The workshop’s Entire string mode requires a complete match. Search anywhere summarizes the first match and lists up to 100 nonoverlapping matches, including empty ones; empty matches advance by a Unicode code point. Open a match to inspect numbered or named captures and jump to their rules. Absent groups show “Not captured”, participating empty groups show an empty string, and repeated groups show their final capture. Positions start at 0 and count UTF-16 code units, with the end excluded: a match after 😀 starts at 2. Engines without native capture indices show values without guessed positions. Entire string also shows rejected partial or empty matches. These modes do not change the copied regex.
Open Edit groups and references to rename a capture, change its type or jump to a reference. Numeric references retain their original targets after renumbering; converting a referenced capture to noncapturing is rejected while the original rules stay intact. In the capture explorer, Highlight marks native input ranges, including empty captures and lookaround captures outside the consumed match. Absent captures and unavailable indices have no guessed highlight. The shared editGroup API is also available from the npm package.
Ranges try the largest count first, then backtrack if the next rule needs it. Add start and end to validate the entire string; an unanchored range can find part of a longer string.
zero or more one of: a, b generates [ab]*: listed characters can repeat, including zero times. zero or more none of: a, b generates [^ab]*: it excludes those characters. The explanations keep membership and exclusion distinct, including after reverse translation.
THE OTHER WAY 🔄
Translate an existing regex
/^[A-Z]{2}-\d{4}$/uOpen Already have a regex? in the workshop, paste the literal, then press Ctrl/Cmd + Enter or choose Translate to rules.
start
2 uppercase letter
"-"
4 digit
endThe translator accepts the documented native JavaScript subset: literals, anchors, classes, greedy/lazy repetition, nested capturing/noncapturing groups, ordered alternatives, backward references, lookaround, boundaries, Unicode properties and v-mode strings/sets. It requires u or v and preserves all eight supported flags. Captures retain names, numbering and native values; composite structures become editable blocks. Literal-only noncapturing groups keep compact literal rules. Review the resulting rules and test your examples. These features are included in npm 0.1.0-dev.5 and this workshop.
Write line breaks as escapes inside a regex literal, for example /^a\nb$/u. A physical line break inside the pattern reports an escape hint. Whitespace outside the literal is ignored.
Control-letter escapes such as \cJ (newline) and \ci (tab) translate in literals, character lists and literal groups. Both ASCII letter cases are supported; controls stay visibly escaped in the rules and generated regex. Non-letter forms such as \c0 are invalid with the required u flag.
Empty non-capturing groups such as (?:), including their supported greedy/lazy repetitions, become 0 any character and generate .{0}. A standalone empty pattern matches blank input in Entire string mode; Search mode finds an empty match at position 0 even in nonempty input. Empty capturing groups remain capture blocks so their values and numbering are preserved. Lazy empty-group repetitions keep lazy on their zero-count rule; lazy support is included in npm 0.1.0-dev.5.
Letter ranges accept [A-Za-z] or [a-zA-Z]. Hex ranges accept all six orders of 0-9, A-F and a-f, such as [0-9a-fA-F] or [A-Fa-f0-9]. They become letter or hex digit; the generated regex uses a canonical range order with equivalent matching.
Complete word classes such as [A-Za-z0-9_] become word (\w); their negation becomes not word (\W). All three ranges and the underscore can be reordered or repeated. The original flags and Unicode case-folding behavior are preserved. Missing parts, extra characters and different ranges keep explicit composable class members instead of being replaced by a word shorthand.
A negative class excluding exactly slash, backslash, NUL, LF, CR, U+2028 and U+2029 becomes path segment character. For example, [^/\\\0\n\r\u2028\u2029] keeps the readable name even when exclusions are reordered, repeated or written with equivalent escapes. Missing or extra exclusions and positive lists keep their explicit character lists.
A literal hyphen can appear at either end of a simple character list, as in [._-] or [-._], including negated lists. [-] becomes "-". Generated classes escape literal hyphens as \-. The compiler also preserves inclusive code-point ranges such as [α-ω] and [😀-🙏].
Assertions: use followed by { … }, not followed by { … }, preceded by { … } or not preceded by { … } with a closing brace on its own line. The condition consumes no characters; captures can lie before or after the consumed match. Lookbehind matches its contents backwards and requires native runtime support. Nested groups, captures, choices and assertions share the 64-level budget. Repeat the contents or a containing group, rather than the assertion itself. Forward/open references remain rejected even inside lookbehind. Included in npm 0.1.0-dev.5.
Word boundaries: word boundary generates \b and not word boundary generates \B. They consume no characters and use native JavaScript word status: ASCII letters, digits and underscore, plus Unicode case-folding equivalents with i. They do not segment natural-language words. Input edges are non-word; \B matches empty input. Direct repetition is rejected; repeat a containing group instead. Inside a character class, [\b] still means backspace. Both translation directions preserve this distinction. Included in npm 0.1.0-dev.5.
Character classes: range "α" to "ω" generates [α-ω]. character class: unicode property "L", unicode property "M", "_" combines native letters, combining marks and underscore. Members may be single-code-point literals, ranges, singular shorthands or Unicode properties. Counts and lazy repeat the whole class; not character class: negates its union. Property complements keep their distinct native u/i behavior. Included in npm 0.1.0-dev.5.
Forward/open references, empty u-mode classes and unsupported engine constructs receive positioned diagnostics. Empty/universal sets and nested union/intersection/subtraction are supported in v mode. Translation errors leave your current rules intact. In the library, use regexToRules(regex) and pass its returned flags to compile(rules, { flags }).
Alternatives translate to editable either { … } blocks, preserving order, precedence and captures. Each immediate entry is one choice; use a group { … } block for a sequence or an empty choice. Existing repetition modifiers apply to the whole choice. At least two choices are required, and all blocks share the 64-level depth budget. Escaped pipes such as \| and character-class pipes such as [|] stay literal matching data.
The translator imports positive/negative lookahead and lookbehind without consuming their context. Unsupported children still fail at their original position: /^😀(?=ab[])a/u points to the empty class’s [ at column 9. Forward/open references point to their original escape. Use Go to regex error to select the source character and bring it into view, including in long patterns. Captures, nested groups and literal parentheses such as \( or [()] translate; unsupported contents leave your current rules and options intact.
The regex pattern and translated rules each have a 16,384 UTF-16 code-unit limit; translated rules also have a 200-line limit. Escaping and separate atoms can make the rules longer than the pattern. Output-limit errors explain this and point to column 1 for the whole regex. Syntax columns count the pattern between the slash delimiters.
Code-point escapes accept leading zeros: \u{00000041} becomes "A", and \u{0001f600} becomes "😀". They work in literals, character lists and literal groups; the complete regex source still has a 16,384-code-unit limit.
A fixed-width Unicode escape pair such as \uD83D\uDE00 is one emoji atom, including inside a character class or before a repetition modifier. Separate surrogate atoms stay separate, including inside repeated group blocks. See the full language contract for exact limits.
Review the pattern
Open Review the pattern for heuristic notes on nested/adjacent variable repetitions, overlapping alternatives, broad wildcards, line anchors and large generated patterns. Hover connects the source rule, regex fragment, explanation and diagram without moving the caret. Select a note to return to its source line. Rule, flag, recipe and group edits refresh the review.
The shared analyze(rules, { flags }) API returns flags, typed source-linked findings and explicit limitations. Unknown character witnesses are not treated as disjointness proofs. Analysis does not run matches or measure backtracking; no findings does not prove performance safety. Example matching continues in an isolated worker with a time limit. See the analysis contract.
Explore the structure
Open Explore the pattern for an AST-driven railroad diagram: nested groups, ordered alternatives, repetition bounds and separate zero-width lookaround checks. Hover or focus a node or explanation to connect source rules and regex fragments without moving the source caret. Select a node with a click or Enter/Space to return to its rule. The source cursor and generated-regex selection also follow the structure.
Actual size keeps labels readable with scrolling; Fit overview scales the whole map. Export SVG saves a standalone image with the current flags, also available from toSVG(rules, { flags }). Long labels retain full explanations in titles. This is structure, not a runtime backtracking trace. Read the structural diagram contract.
BOUNDARIES
Flags and limits
u or vUnicode matching is required. u is the default; v uses native Unicode-set class semantics.
Choose d/g/i/m/s/y with the workshop controls or CLI --flags; u/v are exclusive.
Unscoped line anchors enable m automatically. Input anchors remain absolute when the modes are mixed.
These explicit flag options are included in npm 0.1.0-dev.5. Duplicate flags and unavailable native features receive diagnostics. Native nested sets and intersection/subtraction require v. Each workshop example starts at position 0; sticky y stops at the first gap. Copied g/y regexes use native lastIndex state. Search lists up to 100 matches, using internal g/d for enumeration and indices without changing copied flags.
Local group options: group with flags "im-s" { enables i/m and disables s only inside its block. Close with }; the enclosing options resume afterward. Put captures inside the block, and apply existing repetition prefixes to the whole group. Input anchors remain absolute; explicit line anchors retain line semantics without changing options outside their scope. Only i/m/s are local options. Incompatible runtimes receive a positioned error; the tested Node 22/25/26 editions cannot run this feature correctly. See the scoped syntax and runtime limits and publication status.
In v mode, one of strings: "a", "ab", "" creates a native finite string set. Longer members are tried first, regardless of list order; following rules can require a shorter member. An empty member permits a zero-width match. Use string "ab" within a character class, or unicode property "RGI_Emoji" to match native Unicode emoji sequences. String properties and empty/multi-code-point members cannot be complemented. The reverse translator retains separate surrogate escapes with string code points: "\ud83d" + "\ude00"; the full language contract explains this native distinction. Included in npm 0.1.0-dev.5.
Rules are limited to 16,384 UTF-16 code units, 200 lines and numeric repetition counts up to 1,000. The workshop limits example strings and runs matching in a time-limited worker. These limits do not guarantee that a copied regex is fast in another program.
In v mode, open character set union {, character set intersection { or character set subtraction { and close with }. Each line is one character, range, class, property, string set or nested set. Intersection keeps shared members; subtraction removes right-hand members from the first operand. Counts and lazy preference apply to the whole block. An empty union matches nothing. Native structural rules permit some intersections or subtractions containing strings to be complemented: an intersection needs a character-only operand, and subtraction needs a character-only first operand. Groups and sets share the 64-level nesting budget. See the worked set example. Included in npm 0.1.0-dev.5.
A missing closing quote points to the actual line end, including trailing spaces. Raw control characters inside unfinished quotes still report their own position. Whitespace after a closed quoted value is ignored.
Go to error selects the original quoted escape, property alias, character-list item or range endpoint when its range is known. Columns start at 1 and count UTF-16 code units; an available endColumn is exclusive. Unknown ranges keep point navigation, including at the end of a line. A failed regex import keeps your current rules.
Open Test fixtures to import or export a regression suite with rules, flags, match mode and examples. Exact expectations can check match spans, numbered/named captures, empty captures and replacement results. Copy share link includes the complete suite so another workshop can restore it. Anyone with the full link can read its contents; clipboard failure leaves a manual-copy field, and larger suites can use JSON export.
Failed examples can explain a required literal at the wrong absolute input edge when the rules prove that requirement. Case folding, line anchors and uncertain consumption keep conservative explanations. This does not trace the regex engine's backtracking.
Export to a programming language generates target code and compatibility metadata for Python, Rust, Go, Java, C#, PHP or Ruby, alongside JavaScript output. Unsupported features produce target-specific diagnostics. Workshop examples still run in the JavaScript worker; check the generated snippet and runtime requirements in the receiving application. See the tested engine profiles and limitations.
The preview supports nested group {, numbered capture {, named capture "name" { and ordered either { blocks, closed with } on its own line, including reverse translation. Existing repetition modifiers apply to entire blocks. Captures are numbered in opening order; names must be unique JavaScript identifiers. Use same as capture "name" or same as capture 1 after the target's closing brace. Missing, forward and open/self references receive positioned diagnostics; a reference to an absent optional capture follows JavaScript's empty-text behavior. Nesting is limited to 64 levels. These features are included in npm 0.1.0-dev.5. Raw regex as rule text and other regex engines are outside the current rule language. Read the full language contract ↗, or the local Markdown source ↗ when offline.