You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Oniguruma supports multiple forms of "absence" operators/functions/groups. The basic form (?~…) is extremely rarely used, but at least has good use cases. Other forms (that start with (?~|) are so exceedingly rare that they're probably not worth supporting (and some are likely not emulatable anyway).
On rarity: The basic form was used by two regexes out of tens of thousands in a sample of real-world Oniguruma regexes used in TextMate grammars. The other forms were not used at all.
If I understand Oniguruma's basic form (?~…) correctly, it can be emulated in JS as (?:(?!…)\p{Any})*. Running a few basic tests in Oniguruma show this to be producing the same results. This is a trivial transformation to do in src/transform.js after first adding support for parsing absence operators in src/tokenize.js and src/parse.js.
Additionally:
Absence operators currently throw a custom error here.
The behavior of (?~…) is different in Oniguruma and Onigmo. So Ruby regex testers like rubular.com are not helpful.
Need to test the effects of quantification, whether absence operators are atomic, etc.
Should catch non-basic forms that aren't supported (starting with (?~|) as an error.
It might be easy to also support the "absent expression" form (?~|absent|exp).
Oniguruma itself doesn't support "absent stopper" and "range clear" forms within lookbehind.
The text was updated successfully, but these errors were encountered:
Oniguruma supports multiple forms of "absence" operators/functions/groups. The basic form
(?~…)
is extremely rarely used, but at least has good use cases. Other forms (that start with(?~|
) are so exceedingly rare that they're probably not worth supporting (and some are likely not emulatable anyway).On rarity: The basic form was used by two regexes out of tens of thousands in a sample of real-world Oniguruma regexes used in TextMate grammars. The other forms were not used at all.
If I understand Oniguruma's basic form
(?~…)
correctly, it can be emulated in JS as(?:(?!…)\p{Any})*
. Running a few basic tests in Oniguruma show this to be producing the same results. This is a trivial transformation to do insrc/transform.js
after first adding support for parsing absence operators insrc/tokenize.js
andsrc/parse.js
.Additionally:
(?~…)
is different in Oniguruma and Onigmo. So Ruby regex testers like rubular.com are not helpful.(?~|
) as an error.(?~|absent|exp)
.The text was updated successfully, but these errors were encountered: