Gathering detailed insights and metrics for oniguruma-to-es
Gathering detailed insights and metrics for oniguruma-to-es
Gathering detailed insights and metrics for oniguruma-to-es
Gathering detailed insights and metrics for oniguruma-to-es
👹 Convert patterns from Oniguruma (the regex flavor used by Ruby, TextMate grammars, etc.) to native JavaScript RegExp
npm install oniguruma-to-es
Typescript
Module System
Node Version
NPM Version
99.6
Supply Chain
99.2
Quality
94.5
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
22,122,216
Last Day
255,532
Last Week
1,431,510
Last Month
6,078,789
Last Year
22,122,216
MIT License
115 Stars
631 Commits
4 Forks
5 Watchers
1 Branches
5 Contributors
Updated on May 07, 2025
Minified
Minified + Gzipped
Latest Version
4.3.3
Package Id
oniguruma-to-es@4.3.3
Unpacked Size
971.39 kB
Size
269.28 kB
File Count
25
NPM Version
10.9.2
Node Version
23.11.0
Published on
May 02, 2025
Cumulative downloads
Total Downloads
Last Day
28.8%
255,532
Compared to previous day
Last Week
1.2%
1,431,510
Compared to previous week
Last Month
19.8%
6,078,789
Compared to previous month
Last Year
0%
22,122,216
Compared to previous year
3
4
“I think [Oniguruma-To-ES] is very wonderful”
— K. Kosako, creator of Oniguruma
Oniguruma is a regular expression engine written in C that's used in Ruby (via a fork named Onigmo), PHP (mb_ereg
, etc.), TextMate grammars (used by VS Code, Shiki, etc. for syntax highlighting), and many other tools.
Oniguruma-To-ES is an advanced Oniguruma to JavaScript regex translator that runs in the browser or the server, with support for ~99.99% of Oniguruma regexes (more details below). Use it to:
Compared to running the Oniguruma C library via WASM using vscode-oniguruma, this library is ~4% of the size and its regexes often run much faster (even including transpilation time) since they run as native JavaScript.
[!TIP] You can further reduce bundle size (and increase run-time performance) by precompiling your regexes. In many cases, that avoids the need for any run-time dependency. Conversions for regexes that use certain advanced features rely on a
RegExp
subclass, in which case the tree-shakableEmulatedRegExp
(3 kB minzip) is still needed after precompilation.
Oniguruma-To-ES deeply understands the hundreds of large and small differences between Oniguruma and JavaScript regex syntax and behavior, across multiple JavaScript version targets. It's obsessive about ensuring that the emulated features it supports have exactly the same behavior, even in extreme edge cases. And it's been battle-tested on tens of thousands of real-world Oniguruma regexes used in TextMate grammars. It's built on top of oniguruma-parser and Regex+, both by the same author as this library.
toRegExp
, toRegExpDetails
, EmulatedRegExp
accuracy
, avoidSubclass
, flags
, global
, hasIndices
, lazyCompileLength
, rules
, target
, verbose
1import {toRegExp} from 'oniguruma-to-es'; 2 3toRegExp(String.raw`(?x) 4 (?<n>\d) (?<n>\p{greek}) \k<n> 5 ([0a-z&&\h]){,2} 6`); 7// → /(?<n>\p{Nd})(\p{sc=Greek})(?>\2|\1)(?:[[0a-z]&&\p{AHex}]){0,2}/v
Although the example above is fairly straightforward, it shows several kinds of differences being translated:
x
for insignificant whitespace and comments.(?x)
or the \h
hex-digit shorthand. Note: ES2025 added support for flag groups like (?i:…)
.Greek
, requires nested character classes for intersection of union and ranges, and doesn't allow an implicit 0
min for {…}
quantifiers.\d
is Unicode based by default, backreferences to duplicate group names match the captured value of any of the groups, and (…)
groups are noncapturing by default if named groups are present.Many advanced features are supported that would produce more complicated transformations.
[!NOTE] The
(?>…)
atomic group shown in the result was a simplification for readability. Since JavaScript doesn't support atomic groups, the actual result uses(?=(\2|\1))\3
for the same effect, and then uses aRegExp
subclass to automatically remove the added capturing group from reported matches.
This next example shows support for Unicode case folding with mixed case-sensitivity. Notice that code points ſ
(U+017F) and K
(U+212A) are added to the second, case-insensitive range if using a target
prior to ES2025
, and that modern JavaScript regex features (like flag groups) are used if supported by the target
.
1toRegExp('[a-z](?i)[a-z]', {target: 'ES2018'}); 2// → /[a-z][a-zA-ZſK]/u 3toRegExp('[a-z](?i)[a-z]', {target: 'ES2025'}); 4// → /[a-z](?i:[a-z])/v
1npm install oniguruma-to-es
1import {toRegExp} from 'oniguruma-to-es'; 2 3const str = '…'; 4const pattern = '…'; 5// Works with all string/regexp methods since it returns a native regexp 6str.match(toRegExp(pattern));
1<script src="https://cdn.jsdelivr.net/npm/oniguruma-to-es/dist/index.min.js"></script> 2<script> 3 const {toRegExp} = OnigurumaToEs; 4</script>
toRegExp
Accepts an Oniguruma pattern and returns an equivalent JavaScript RegExp
.
[!TIP] Try it in the demo REPL.
1function toRegExp(
2 pattern: string,
3 options?: ToRegExpOptions
4): RegExp | EmulatedRegExp;
ToRegExpOptions
1type ToRegExpOptions = { 2 accuracy?: 'default' | 'strict'; 3 avoidSubclass?: boolean; 4 flags?: string; 5 global?: boolean; 6 hasIndices?: boolean; 7 lazyCompileLength?: number; 8 rules?: { 9 allowOrphanBackrefs?: boolean; 10 asciiWordBoundaries?: boolean; 11 captureGroup?: boolean; 12 recursionLimit?: number; 13 singleline?: boolean; 14 }; 15 target?: 'auto' | 'ES2025' | 'ES2024' | 'ES2018'; 16 verbose?: boolean; 17};
See Options for more details.
toRegExpDetails
Accepts an Oniguruma pattern and returns the details needed to construct an equivalent JavaScript RegExp
.
1function toRegExpDetails(
2 pattern: string,
3 options?: ToRegExpOptions
4): {
5 pattern: string;
6 flags: string;
7 options?: EmulatedRegExpOptions;
8};
Note that the returned flags
might also be different than those provided, as a result of the emulation process. The returned pattern
, flags
, and options
properties can be provided as arguments to the EmulatedRegExp
constructor to produce the same result as toRegExp
.
If the only keys returned are pattern
and flags
, they can optionally be provided to JavaScript's RegExp
constructor instead. Setting option avoidSubclass
to true
ensures that this is always the case (resulting in an error for any patterns that require EmulatedRegExp
's additional handling).
EmulatedRegExp
Works the same as JavaScript's native RegExp
constructor in all contexts, but can be given results from toRegExpDetails
to produce the same result as toRegExp
.
1class EmulatedRegExp extends RegExp { 2 constructor(pattern: string, flags?: string, options?: EmulatedRegExpOptions); 3 constructor(pattern: EmulatedRegExp, flags?: string); 4 rawOptions: EmulatedRegExpOptions; 5}
The rawOptions
property of EmulatedRegExp
instances can be used for serialization.
EmulatedRegExpOptions
1type EmulatedRegExpOptions = { 2 hiddenCaptures?: Array<number>; 3 lazyCompile?: boolean; 4 strategy?: string | null; 5 transfers?: Array<[number, Array<number>]>; 6};
The following options are shared by functions toRegExp
and toRegExpDetails
.
accuracy
One of 'default'
(default) or 'strict'
.
Sets the level of emulation rigor/strictness.
target
.Using default accuracy
adds support for the following features, depending on target
:
ES2025
and earlier):
\X
using a close approximation of a Unicode extended grapheme cluster.\G
that rely on subclass-based emulation.ES2024
and earlier:
ES2018
:
[:graph:]
and [:print:]
using ASCII versions rather than the Unicode versions available for ES2024
and later. Other POSIX classes are always Unicode based.avoidSubclass
Default: false
.
Disables advanced emulation that relies on returning a RegExp
subclass. In cases when a subclass would otherwise have been used, this results in one of the following:
groups
, and indices
).flags
Oniguruma flags; a string with i
, m
, x
, D
, S
, W
, y{g}
in any order (all optional).
Flags i
, m
, x
can also be specified via modifiers in the pattern.
[!IMPORTANT] Oniguruma and JavaScript both have an
m
flag but with different meanings. Oniguruma'sm
is equivalent to JavaScript'ss
(dotAll
).
global
Default: false
.
Include JavaScript flag g
(global
) in the result.
hasIndices
Default: false
.
Include JavaScript flag d
(hasIndices
) in the result.
lazyCompileLength
Default: Infinity
. In other words, lazy compilation is off by default.
Delay regex construction until first use if the transpiled pattern is at least this length.
Although regex construction in JavaScript is fast, it can sometimes be helpful to defer the cost for extremely long patterns. Lazy compilation defers the time JavaScript spends inside the RegExp
constructor (building the transpiled pattern into a regex object) until the first time the regex is used in a search. The regex object is outwardly identical before and after deferred compilation.
Lazy compilation relies on the EmulatedRegExp
class.
rules
Advanced options that override standard behavior, error checking, and flags when enabled.
allowOrphanBackrefs
: Useful with TextMate grammars that merge backreferences across patterns.asciiWordBoundaries
: Use ASCII \b
and \B
, which increases search performance of generated regexes.captureGroup
: Allow unnamed captures and numbered calls (backreferences and subroutines) when using named capture.
ONIG_OPTION_CAPTURE_GROUP
; on by default in vscode-oniguruma
.recursionLimit
: Change the recursion depth limit from Oniguruma's 20
to an integer 2
–20
.singleline
: ^
as \A
; $
as \Z
. Improves search performance of generated regexes without changing the meaning if searching line by line.
ONIG_OPTION_SINGLELINE
.target
One of 'auto'
(default), 'ES2025'
, 'ES2024'
, or 'ES2018'
.
JavaScript version used for generated regexes. Using auto
detects the best value for your environment. Later targets enable faster transpilation, simpler generated source, and support for additional features.
ES2018
: Uses JS flag u
.
ES2024
: Uses JS flag v
.
ES2025
: Uses JS flag v
and allows use of flag groups.
verbose
Default: false
.
Disables minifications that simplify the pattern without changing the meaning.
Example: By default, unneeded noncapturing groups might be removed during transpilation. Setting this option to true
disables such changes.
[!TIP] The oniguruma-parser library includes a regex optimizer that goes far beyond the basic, built-in minifications. If desired, you can call the optimizer first, and then use its result for transpilation. That isn't appropropriate in all cases (since it adds performance overhead and increases bundle size), but the benefits of optimization do pass through to the transpiled, JavaScript version of a regex.
Following are the supported features by target. The official Oniguruma syntax doc doesn't cover many of the finer details described here.
[!NOTE] Targets
ES2024
andES2025
have the same emulation capabilities. Resulting regexes might have different source and flags, but they match the same strings. Seetarget
.
🆕 = Syntax not available in JavaScript.
🆚 = JavaScript uses slightly different syntax for the same concept; ex: \x{…}
→ \u{…}
.
Even for features not marked with one of the above symbols, notice that nearly every feature below has at least subtle differences from JavaScript. Unsupported features throw an error.
Feature | Example | ES2018 | ES2024+ | Subfeatures & JS differences | |
---|---|---|---|---|---|
Characters | Literal | E , ! | ✅ | ✅ |
✔ Code point based matching (same as JS with flag u , v )✔ Standalone ] , { , } don't require escaping |
Identity escape | \E , \! | ✅ | ✅ |
✔ Different set than JS ✔ Allows multibyte chars | |
Escaped metachar | \\ , \. | ✅ | ✅ |
✔ Same as JS | |
Control code escape | \t | ✅ | ✅ |
✔ The JS set plus \a , \e | |
\xNN | \x7F | ✅ | ✅ |
✔ Allows 1 hex digit ✔ Above 7F , is UTF-8 encoded byte (≠ JS)✔ Error for invalid encoded bytes | |
\uNNNN | \uFFFF | ✅ | ✅ |
✔ Same as JS with flag u , v | |
🆚 \x{…} | \x{A} | ✅ | ✅ |
✔ Allows leading 0s up to 8 total hex digits | |
Escaped num | \20 | ✅ | ✅ |
✔ Can be backref, error, null, octal, identity escape, or any of these combined with literal digits, based on complex rules that differ from JS ✔ Always handles escaped single digit 1-9 outside char class as backref ✔ Allows null with 1-3 0s ✔ Error for octal ≥ 200 | |
Caret notation |
\cA ,🆚 \C-A
| ✅ | ✅ |
✔ With A-Za-z (JS: only \c form) | |
Character sets | Digit | \d , \D | ✅ | ✅ |
✔ Unicode by default (≠ JS) |
Word | \w , \W | ✅ | ✅ |
✔ Unicode by default (≠ JS) | |
Whitespace | \s , \S | ✅ | ✅ |
✔ Unicode by default ✔ No JS adjustments to Unicode set (− \uFEFF , +\x85 ) | |
🆕 Hex digit | \h , \H | ✅ | ✅ |
✔ ASCII | |
Dot | . | ✅ | ✅ |
✔ Excludes only \n (≠ JS) | |
🆕 Any | \O | ✅ | ✅ |
✔ Any char (with any flags) ✔ Identity escape in char class | |
🆕 Not \n | \N | ✅ | ✅ |
✔ Identity escape in char class | |
🆕 Newline | \R | ✅ | ✅ |
✔ Matched atomically ✔ Identity escape in char class | |
🆕 Grapheme | \X | ☑️ | ☑️ |
● Uses a close approximation ✔ Matched atomically ✔ Identity escape in char class | |
Unicode property |
\p{L} ,\P{L}
| ✅ | ✅ |
✔ Binary properties ✔ Categories ✔ Scripts ✔ Aliases ✔ POSIX properties ✔ Invert with \p{^…} , \P{^…} ✔ Insignificant spaces, hyphens, underscores, and casing in names ✔ \p , \P without { is an identity escape✔ Error for key prefixes ✔ Error for props of strings ❌ Blocks (wontfix[1]) | |
Character classes | Base | […] , [^…] | ✅ | ✅ |
✔ Unescaped - outside of range is literal in some contexts (different than JS rules in any mode)✔ Leading unescaped ] is literal✔ Fewer chars require escaping than JS |
Range | [a-z] | ✅ | ✅ |
✔ Same as JS with flag u , v ✔ Allows \x{…} above 10FFFF at end of range to mean last valid code point | |
🆕 POSIX class |
[[:word:]] ,[[:^word:]]
| ☑️[2] | ✅ |
✔ All use Unicode definitions | |
Nested class | […[…]] | ☑️[3] | ✅ |
✔ Same as JS with flag v | |
Intersection | […&&…] | ❌ | ✅ |
✔ Doesn't require nested classes for intersection of union and ranges ✔ Allows empty segments | |
Assertions | Line start, end | ^ , $ | ✅ | ✅ |
✔ Always "multiline" ✔ Only \n as newline✔ ^ doesn't match after string-terminating \n |
🆕 String start, end | \A , \z | ✅ | ✅ |
✔ Same as JS ^ $ without JS flag m | |
🆕 String end or before terminating newline | \Z | ✅ | ✅ |
✔ Only \n as newline | |
🆕 Search start | \G | ✅ | ✅ |
✔ Matches at start of match attempt (not end of prev match; advances after 0-length match) | |
Word boundary | \b , \B | ✅ | ✅ |
✔ Unicode based (≠ JS) | |
Lookaround |
(?=…) ,(?!…) ,(?<=…) ,(?<!…)
| ✅ | ✅ |
✔ Allows variable-length quantifiers and alternation within lookbehind ✔ Lookahead invalid within lookbehind ✔ Capturing groups invalid within negative lookbehind ✔ Negative lookbehind invalid within positive lookbehind | |
Quantifiers | Greedy, lazy | * , +? , {2,} , etc. | ✅ | ✅ |
✔ Includes all JS forms ✔ Adds {,n} for min 0✔ Explicit bounds have upper limit of 100,000 (unlimited in JS) ✔ Error with assertions (same as JS with flag u , v ) and directives |
🆕 Possessive | ?+ , *+ , ++ , {3,2} | ✅ | ✅ |
✔ + suffix doesn't make {…} quantifiers possessive (creates a quantifier chain)✔ Reversed {…} ranges are possessive | |
🆕 Chained | ** , ??+* , {2,3}+ , etc. | ✅ | ✅ |
✔ Further repeats the preceding repetition | |
Groups | Noncapturing | (?:…) | ✅ | ✅ |
✔ Same as JS |
🆕 Atomic | (?>…) | ✅ | ✅ |
✔ Supported | |
Capturing | (…) | ✅ | ✅ |
✔ Is noncapturing if named capture present | |
Named capturing |
(?<a>…) ,🆚 (?'a'…)
| ✅ | ✅ |
✔ Duplicate names allowed (including within the same alternation path) unless directly referenced by a subroutine ✔ Error for names invalid in Oniguruma (more permissive than JS) | |
Backreferences | Numbered | \1 | ✅ | ✅ |
✔ Error if named capture used ✔ Refs the most recent of a capture/subroutine set |
🆕 Enclosed numbered, relative |
\k<1> ,\k'1' ,\k<-1> ,\k'-1'
| ✅ | ✅ |
✔ Error if named capture used ✔ Allows leading 0s ✔ Refs the most recent of a capture/subroutine set ✔ \k without < or ' is an identity escape | |
Named |
\k<a> ,🆚 \k'a'
| ✅ | ✅ |
✔ For duplicate group names, rematch any of their matches (multiplex), atomically ✔ Refs the most recent of a capture/subroutine set (no multiplex) ✔ Combination of multiplex and most recent of capture/subroutine set if duplicate name is indirectly created by a subroutine ✔ Error for backref to valid group name that includes - /+ | |
To nonparticipating groups | ☑️ | ☑️ |
✔ Error if group to the right[4] ✔ Duplicate names (and subroutines) to the right not included in multiplex ✔ Fail to match (or don't include in multiplex) ancestor groups and groups in preceding alternation paths ❌ Some rare cases are indeterminable at compile time and use the JS behavior of matching an empty string | ||
Subroutines | 🆕 Numbered, relative |
\g<1> ,\g'1' ,\g<-1> ,\g'-1' ,\g<+1> ,\g'+1'
| ✅ | ✅ |
✔ Error if named capture used ✔ Allows leading 0s All subroutines (incl. named): ✔ Allowed before reffed group ✔ Can be nested (any depth) ✔ Reuses flags from the reffed group (ignores local flags) ✔ Replaces most recent captured values (for backrefs) ✔ \g without < or ' is an identity escape |
🆕 Named |
\g<a> ,\g'a'
| ✅ | ✅ |
● Same behavior as numbered ✔ Error if reffed group uses duplicate name | |
Recursion | 🆕 Full pattern |
\g<0> ,\g'0'
| ☑️[5] | ☑️[5] |
✔ 20-level depth limit |
🆕 Numbered, relative, named |
(…\g<1>?…) ,(…\g<-1>?…) ,(?<a>…\g<a>?…) , etc.
| ☑️[5] | ☑️[5] |
✔ 20-level depth limit | |
Other | Alternation | …|… | ✅ | ✅ |
✔ Same as JS |
🆕 Absence repeater[6] | (?~…) | ✅ | ✅ |
✔ Supported | |
🆕 Comment group | (?#…) | ✅ | ✅ |
✔ Allows escaping \) , \\ ✔ Comments allowed between a token and its quantifier ✔ Comments between a quantifier and the ? /+ that makes it lazy/possessive changes it to a quantifier chain | |
🆕 Fail[7] | (*FAIL) | ✅ | ✅ |
✔ Supported | |
🆕 Keep | \K | ☑️ | ☑️ |
● Supported at top level if no top-level alternation is used | |
JS features unknown to Oniguruma are handled using Oniguruma syntax rules | ✅ | ✅ |
✔ \u{…} is an error✔ [] , [^] are errors✔ [\q{…}] matches q , etc.✔ [a--b] includes the invalid reversed range a to - | ||
Invalid Oniguruma syntax | ✅ | ✅ |
✔ Error | ||
Flags | Supported in top-level flags and flag modifiers | ||||
Ignore case | i | ✅ | ✅ |
✔ Unicode case folding (same as JS with flag u , v )[8] | |
🆚 Dot all | m | ✅ | ✅ |
✔ Equivalent to JS flag s | |
🆕 Extended | x | ✅ | ✅ |
✔ Unicode whitespace ignored ✔ Line comments with # ✔ Whitespace/comments allowed between a token and its quantifier ✔ Whitespace/comments between a quantifier and the ? /+ that makes it lazy/possessive changes it to a quantifier chain✔ Whitespace/comments separate tokens (ex: \1 0 )✔ Whitespace and # not ignored in char classes | |
Currently supported only in top-level flags | |||||
🆕 Digit is ASCII | D | ✅ | ✅ |
✔ ASCII \d , \p{Digit} , etc. | |
🆕 Space is ASCII | S | ✅ | ✅ |
✔ ASCII \s , \p{Space} , etc. | |
🆕 Word is ASCII[9] | W | ✅ | ✅ |
✔ ASCII \w , \p{Word} , \b , etc. | |
🆕 Text segment mode is grapheme | y{g} | ✅ | ✅ |
✔ Grapheme based \X , \y | |
Flag modifiers | Group | (?im-x:…) | ✅ | ✅ |
✔ Unicode case folding for i ✔ Allows enabling and disabling the same flag (priority: disable) ✔ Allows lone or multiple - |
🆕 Directive | (?im-x) | ✅ | ✅ |
✔ Continues until end of pattern or group (spanning alternatives) | |
Compile-time options | ONIG_OPTION_CAPTURE_GROUP | ✅ | ✅ |
✔ Unnamed captures and numbered calls allowed when using named capture | |
ONIG_OPTION_SINGLELINE | ✅ | ✅ |
✔ ^ → \A ✔ $ → \Z |
The table above doesn't include all aspects that Oniguruma-To-ES emulates (including error handling, subpattern details on match results, most aspects that work the same as in JavaScript, and many aspects of non-JavaScript features that work the same in the other regex flavors that support them). Where applicable, Oniguruma-To-ES follows the latest version of Oniguruma (6.9.10).
In
prefix) are easily emulatable but their character data would significantly increase library weight. They're also rarely used, fundamentally flawed, and arguably unuseful given the availability of Unicode scripts and other properties.ES2018
, the specific POSIX classes [:graph:]
and [:print:]
use ASCII versions rather than the Unicode versions available for target ES2024
and later, and they result in an error if using strict accuracy
.ES2018
has limited support for nested, negated character classes.\10
or higher and not as many capturing groups are defined to the left (it's an octal or identity escape).20
. Oniguruma-To-ES uses the same limit by default but allows customizing it via the rules.recursionLimit
option. Two rare uses of recursion aren't yet supported: overlapping recursions, and use of backreferences when a recursed subpattern contains captures. Patterns that would trigger an infinite recursion error in Oniguruma might find a match in Oniguruma-To-ES (since recursion is bounded), but future versions will detect this and error at transpilation time.(?~|
and are extremely rare. Note that absence functions behave differently in Oniguruma and Onigmo.(*…)
and are extremely rare.i
, in rare cases Oniguruma can change the length of certain matches based on Unicode case conversion rules. That behavior isn't reproduced in this library because ① the rules are applied inconsistently (report) and ② Oniguruma planned to disable case conversion length changes by default in future versions.W
and i
can result in edge case Oniguruma bugs (report) that aren't reproduced in this library.The following throw errors since they aren't yet supported. They're all extremely rare.
\cx
\C-x
, meta \M-x
\M-\C-x
, octal code points \o{…}
, and octal encoded bytes ≥ \200
.\x{H H …}
\o{O O …}
.P
(POSIX is ASCII) and y{w}
(text segment mode is word), and whole-pattern flag C
(don't capture group).(?(…)…)
, etc.I
(ignore-case is ASCII) and L
(find longest).(*SKIP)
.\y
\Y
.(?{…})
, and most named callouts.See also the supported features table (above), which describes some additional, rarely-used sub-features that aren't yet supported.
Despite these gaps, ~99.99% of real-world Oniguruma regexes are supported, based on a sample of ~55k regexes used in TextMate grammars. Conditionals were used in three regexes, overlapping recursions in three regexes, and other unsupported features weren't used at all. Some Oniguruma features are so exotic that they aren't used in any public code on GitHub.
Oniguruma-To-ES fully supports mixed case-sensitivity (ex: (?i)a(?-i)a
) and handles the Unicode edge cases regardless of JavaScript target.
Oniguruma-To-ES focuses on being lightweight to make it better for use in browsers. This is partly achieved by not including heavyweight Unicode character data, which imposes a few minor/rare restrictions:
ES2018
. Use target ES2024
(supported by Node.js 20 and 2023-era browsers) or later if you need support for these features.ES2025
, a handful of Unicode properties that target a specific character case (ex: \p{Lower}
) can't be used case-insensitively in patterns that contain other characters with a specific case that are used case-sensitively.
A\p{Lower}
, (?i)A\p{Lower}
, (?i:A)\p{Lower}
, (?i)A(?-i)\p{Lower}
, and \w(?i)\p{Lower}
, but not A(?i)\p{Lower}
.\p{…}
that were added in a later version of Unicode than the environment supports results in a runtime error. This is an extreme edge case since modern JavaScript environments support recent versions of Unicode.Contributions are welcome. See the guide to help you get started.
JsRegex transpiles Ruby regexes to JavaScript. Ruby uses Onigmo, a fork of Oniguruma. Although JsRegex and this library have important differences, JsRegex might be a better fit for some Ruby projects.
Oniguruma-To-ES was created by Steven Levithan and contributors.
Special thanks:
If you want to support this project, I'd love your help by contributing improvements (guide), sharing it with others, or sponsoring ongoing development.
MIT License.
No vulnerabilities found.
No security vulnerabilities found.