NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
npm · #3255 most downloaded on npm
Parse, validate, traverse, transform, and optimize Oniguruma regular expressions
Last release 5 months ago
19 Apr 2026
Ships unpredictably
gaps range from 8 days to 12 months
Nearly every release is documented
notes for 23 of 25 stable releases
Nothing withdrawn
no release was ever pulled
2 years old
25 releases · first in 2025
One column per month.
Parser: Improved the error message for unclosed character classes that start with unescaped ] to be more accurate/helpful.
] to be more accurate/helpful.Optimizer: Updated optimization optionalize to apply in more cases.
optionalize to apply in more cases.This release adds support for a minor and rarely-used feature (flag y{g}/y{w}), and makes the relevant changes throughout the library to support it. T
This release adds support for a minor and rarely-used feature (flag y{g}/y{w}), and makes the relevant changes throughout the library to support it. This flag changes the meaning of character set \X and assertions \y \Y to be based on either graphemes (the default) or word boundaries (using the definition from TR 29, which is different than \b).
kind values, for nodes that can switch to not being grapheme based via flag y{w}.
Assertion kind 'grapheme_boundary' as 'text_segment_boundary'.CharacterSet kind 'grapheme' as 'text_segment'.y{g}/y{w} via option flags. Note: Not yet supported via pattern modifiers.Flags node now includes property textSegmentMode with value null, 'grapheme', or 'word' (which capture the state of flag y{g}/y{w}).y{g}/y{w}.removeUselessFlags to remove y{g} from top-level flags.y{g} or y{w}.Optimizer: Added optimization optionalize, which combines adjacent alternatives with only an added last node as the difference.
optionalize, which combines adjacent alternatives with only an added last node as the difference.Optimizer: Improved the contextual logic about when to apply the extractSuffix and mergeRanges optimizations. They're now less aggressively applied in
extractSuffix and mergeRanges optimizations. They're now less aggressively applied in cases where they weren't wrong but they also weren't always beneficial or could slightly lengthen the pattern.A quick follow-up release to rename a recently-added informational node property, and support a syntax edge case.
A quick follow-up release to rename a recently-added informational node property, and support a syntax edge case.
hasSubroutine to isSubroutined (i.e., the group is directly referenced by one or more subroutines anywhere within the regex).? quantifier. Previously threw a custom error. (#10)This release includes numerous quality-of-life improvements for traversing and transforming OnigurumaAsts. It might require updating your code, but th
This release includes numerous quality-of-life improvements for traversing and transforming OnigurumaAsts. It might require updating your code, but the result should be cleaner and simpler than before.
alternatives, elements, element, and pattern → body. (#12)Pattern; its children are now held one level up, in the Regex node's body array. (#12)AbsentFunction → AbsenceFunction. (#23)createPattern and type PatternNode (since they're no longer relevant), and updated createRegex to no longer accept a pattern argument. (#12)createCapturingGroup's optional name argument to a new options object.AbsentFunctionNode → AbsenceFunctionNode, createAbsentFunction → createAbsenceFunction, NodeAbsentFunctionKind → NodeAbsenceFunctionKind. (#23)NodeType, which for the last couple versions has just been an alias for type Node['type'].Recursion nodes, which were never included in OnigurumaAsts (Subroutine nodes are used for recursion). It was previously included to support Oniguruma-To-ES. (#3)traverse and type Visitor to require nullish or nonprimitive values as the traversal state.hasOnlyChild, isAlternativeContainer, and isQuantifiable.body option to functions createAbsenceFunction, createAlternative, createCapturingGroup, createCharacterClass, createGroup, createLookaroundAssertion, and createRegex, to simplify creating multiple nodes at the same time.createCapturingGroup: Added option hasSubroutine to allow setting this existing property for new nodes.createGroup: Throw if option atomic is true and flags provided.path argument automatically. For example, path.node now has type CharacterNode if the visitor's key is Character, and path.parent only includes null as a type option if the visitor's key is Regex or '*'.traverse to allow starting traversal from an AST midpoint. The Path type now takes an optional second argument to specify the root node's type.mergeRanges, replacing the prior dedupeClasses with expanded capabilities. It now merges and sorts ranges and characters in classes, in addition to deduping.simplifyCallouts to convert (*FAIL) to (?!).Traverser: Run the visitor's '*' exit function last, after the node type's exit (if any).
'*' exit function last, after the node type's exit (if any).NamedCallout. (@RedCMD, #21)hasSubroutine for CapturingGroup nodes. (#6)ParseOptions.extractSuffix.exposeAnchors.simplifyCallouts. (@RedCMD, #21)unwrapUselessGroups to apply to noncapturing groups with multiple alternatives if they're the only child of a node that can contain alternatives.removeEmptyGroups to apply to positive lookarounds and absent repeaters.OptimizeOptions.ToOnigurumaAstOptions.The first TypeScript release! Thanks to @RedCMD for taking on the migration. ✨
The first TypeScript release! Thanks to @RedCMD for taking on the migration. ✨
createQuantifier:
kind and element) for consistency.kind required (previously defaulted to 'greedy').kind to 'possessive' with reversed min/max when min > max. All arguments must now be set explicitly.NodeTypes constants in favor of the existing NodeType type, and replaced various other constants (NodeAbsentFunctionKinds, NodeAssertionKinds, NodeCharacterClassKinds, NodeCharacterSetKinds, NodeDirectiveKinds, NodeLookaroundAssertionKinds, NodeQuantifierKinds) with new types.] when it's the leading character in a character class. (@RedCMD)? ignored the chained ?; now throws instead as unsupported. (#10)Generator: Contextually avoid escaping caret and hyphen characters in character classes.
rules.allowOrphanBackrefs, sometimes needed for regexes used in TextMate grammars.allowOrphanBackrefs.OnigUnicodePropertyMap to global name OnigurumaParser.Generator: Improved and fixed some representations for complex quantifier chains.
Optimizer: Optimization preventReDoS no longer applies in cases when it could change captured (subpattern) results.
preventReDoS no longer applies in cases when it could change captured (subpattern) results.Optimizer: Added optimization preventReDoS.
preventReDoS.{1,}++.Generator: Throw for invalid quantifier states that can only happen if an AST was modified in an invalid way after parsing.
path.replaceWithMultiple when a preceding sibling has already been replaced with multiple nodes.a+{0,1} as a+?).unwrapNegationWrappers to avoid introducing a potential trigger for a vscode-oniguruma bug when unwrapping [^\n].Generator: Don't escape literal character }.
}.path.replaceWithMultiple issue that was sometimes causing optimization unwrapUselessGroups to produce incorrect results.Added missing type declaration files.
Optimizer: Added optimization unwrapNegationWrappers, which split duplicated logic from the existing unwrapUselessClasses and unnestUselessClasses tra
unwrapNegationWrappers, which split duplicated logic from the existing unwrapUselessClasses and unnestUselessClasses transforms, and added support for [^\n] → \N when not nested within a class.Generator: Include flag x in returned top-level flags, despite its effects always being applied to the output.
x in returned top-level flags, despite its effects always being applied to the output.removeUselessFlags: Strips flag x from top-level flags, flag groups, and flag directives; and removes directives that only modify flag x.unwrapUselessGroups to no longer unwrap flag groups with x unless the flag has already been stripped by removeUselessFlags.unwrapUselessClasses and unnestUselessClasses to unwrap/unnest negated classes that contain a single, invertible set.useShorthands to convert \p{Any} → \O when not in a class.useUnicodeProps, and split some functionality from useShorthands into it. Added new support for use in intersection classes.unnestOnlyChildClasses into unnestUselessClasses.Optimizer: Improved the useShorthands optimization:
useShorthands optimization:
[\0-\x{10FFFF}] → [\p{Any}].useShorthands to fix an edge case with intersection classes.Added optimization extractPrefix2.
extractPrefix2.useShorthands to convert [0-9A-Fa-f] → \h and, depending on flags, [\p{L}\p{M}\p{N}\p{Pc}] → \w.Added optimization alternationToClass.
alternationToClass.extractPrefix.useShorthands.useUnicodeAliases.getOptionalOptimizations to the included functions.A quick follow-up release to rename a function and improve the optimizer.
A quick follow-up release to rename a function and improve the optimizer.
getAllOptimizations to getOptionalOptimizations.dedupeClasses.Initial release. Following are the changes compared to the last version of this parser that appeared in Oniguruma-To-ES, from where this library origi
Initial release. Following are the changes compared to the last version of this parser that appeared in Oniguruma-To-ES, from where this library originated.
OnigurumaAst.toOnigurumaAst now provides the full list of Oniguruma's supported Unicode properties to the parser.
parse directly allows providing a custom property list and/or relying on best-effort normalization.toOnigurumaAst throws if the second argument isn't an object or undefined.\y \Y.P (posixIsAscii) as a top-level flag.normalizeUnknownPropertyNames and unicodePropertyMap allow providing custom Unicode property data.
createUnicodeProperty.verbose option. The prior, limited optimization is no longer available via the parser.Assertion: Split this node type into Assertion and LookaroundAssertion.CharacterClassIntersection: Removed this node type.
CharacterClass now includes property kind with values 'intersection' and 'union'.VariableLengthCharacterSet: Removed this node type.
CharacterSet now includes kinds 'grapheme' and 'newline', which set the new property variableLength.CharacterSet: Changed the representation of \N from kind 'non_newline' to 'newline' with negate true.
negate is false, kind 'newline' represents variable-length \R, which isn't a simple inversion of \N.CharacterSet: POSIX class names used with Unicode property syntax (ex: \p{Alpha}) now always use kind 'posix'.
unicodePropertyMap.kind 'posix' (alnum, blank, graph, print, word, xdigit) and others with kind 'property' (alpha, ascii, cntrl, digit, lower, punct, space, upper).Quantifier: Replaced the greedy and possessive boolean properties with kind (values: 'greedy', 'lazy', 'possessive').parent properties.
parent properties on all AST nodes by simply running the following:traverse(ast, {
'*'({node, parent}) {
node.parent = parent;
},
});
path object as the first argument.state from the second to the third argument.'*', which runs first before any type-specific transforms.
AstTypeAliases.AnyNode, which didn't support use alongside additional transforms for specific node types.path.remove or path.replaceWith are called.
traverse to path.replaceWith.path.replaceWithMultiple.path.ast as path.root.Nothing published for this version
Nothing published for this version
Your coding agent can read these notes before it upgrades. Set up the MCP server →