Skip to content
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

[feature] consider using fancy-regex to support look-around and backtracking #763

Closed
eugenesvk opened this issue Dec 10, 2023 · 4 comments
Closed
Labels
enhancement New feature or request

Comments

@eugenesvk
Copy link

⭐ Suggestion

Currently ast-grep regex support is missing a couple of features

The regular expression is written in Rust syntax, not the popular PCRE like syntax. So some features are not available like arbitrary look-ahead and back references."

However, there is this fancy regex crate that implements "look-around and backtracking" https://github.com/fancy-regex/fancy-regex, so it might be better to use that instead of the default regex

💻 Use Cases

Same use cases where you'd use regex, but richer and allowing for better matches

@eugenesvk eugenesvk added the enhancement New feature or request label Dec 10, 2023
@HerringtonDarkholme
Copy link
Member

Hi, thanks for the suggestion.

fancy-regex looks like not as mature as regex. I would await more feedback and benchmarks about fancy-regex for its integration.

@HerringtonDarkholme
Copy link
Member

HerringtonDarkholme commented Dec 12, 2023

From fancy-regex's README

Still in development, though the basic ideas are in place. Currently, the following features are missing:

The status was committed 7 years ago, telling from git blame...

Looking at its issue list, I can see these opening bugs:

I sincerely don't think fancy-regex is production-ready now.

@HerringtonDarkholme HerringtonDarkholme closed this as not planned Won't fix, can't repro, duplicate, stale Dec 12, 2023
@eugenesvk
Copy link
Author

Well, you could get feedback and benchmarks in the most important use case - AST-grepping - by adding that as an optional engine :)

Though from my "searching end user" perspective the issues linked are dwarfed by the lack of look-ahead and back-references, those I use often in alternative engines, and it's a big limitation of the "production ready" Rust's default one (even if the back-references,bugs in cases like [\042\223\224\262\263\271]{2}\S{0,16}[\042\223\224\262\263\271]{2} that I'll never encounter and some fuzzed incantation I'll also never use fails)

@HerringtonDarkholme
Copy link
Member

@eugenesvk Would you like to give me an example where you have to use lookaround operator? That will help me understand your use case.

Also, you can use JS API or Python API if lookahead/lookbehind is critical for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants