-
-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support look-behind assertions without constant size #74
Comments
A few example rules that fail:
|
Hey! Hm that's an interesting use case :). So the current implementation of how to match look-behinds is to go back the exact number of characters in the string and then match the expression in the look-behind from there. For that to work, the expression must be a constant size (so not contain There is a good explanation of what various engines support here: https://www.regular-expressions.info/lookaround.html#limitbehind And the Wikipedia page also says that depending on which tool you use some rules might be skipped: https://en.wikipedia.org/wiki/Wikipedia:AutoWikiBrowser/Typos#Usage The most generic implementation that would allow all kinds of expressions is to actually match the look-behind backwards (in reverse). It's not planned to implement that at the moment. |
The new It seems they expose the reverse matching capability in some engines as well. Possibly this can be used to add support for simpler look-behind assertions without the constant length limitation? |
related issue: #2057 This pr implements the same function with rollup's preventAssignment: https://github.com/rollup/plugins/blob/master/packages/replace/src/index.js#L77-L82 And part of the logic is put into the match loop, because of `fancy-regex`'s limitation that variable size of expression cannot be used in lookbehind (fancy-regex/fancy-regex#74 and fancy-regex/fancy-regex#109)
I've been playing around with Wikipedia's RegExTypoFix project: https://en.wikipedia.org/wiki/Wikipedia:AutoWikiBrowser/Typos
While most of the rules compile with fancy-regex, there are a few hundred that fail with error "Look-behind assertion without constant size", you can try it out at https://github.com/intgr/topy-rs
Not sure how difficult the implementation would be.
The text was updated successfully, but these errors were encountered: