fancy-regex 0.2.0: Pure Rust library for regexes with look-around and backreferences
I'm happy to announce the 0.2.0 release of fancy-regex, a library built on top of the regex crate to add support for fancy features such as look-ahead/behind and backreferences.
See the README for a more detailed introduction. Note that supporting fancy features means giving up the linear runtime guarantee of the regex crate - you have been warned :).
This release contains a lot of bug fixes, documentation and tests, see changelog.
The main author is u/raphlinus, I helped polish it.
Posted Oct 18, 2019, 10:33 PM UTC
887
This is super cool! I could see using this in Artichoke Ruby.
I have a WIP implementation of the first technique described in the README. At Ruby
Regexpcompile, create an oniguruma and a Regex backed Regex. Then depending on whether Regex can parse the pattern and some properties of the pattern and target String, select one implementation to do the match.Do you have docs on what Regexp literals fancy-regex supports that Regex does not? I’d love to delegate this complex bit of code to a crate. I’d also love to be rid of the onig_sys C dep.
One last question: the
PERFORMANCE.mdguide in Regex mentions a pathological performance behavior related to\bwith non-ASCII text. Does this case mark the\bas hard? Does the backtracking engine handle this case better?Thanks! Cool project, first time I hear about it :)!
There's a small guide of additional syntax in the docs.
Yeah, trying to get rid of the onig dependency in syntect is also what motivated me to work on fancy-regex, see this PR. In general we're happy to add additional support for Oniguruma syntax.
\bby itself is not marked as hard, so it is executed with the regex crate. Even in a pattern that contains other hard parts, the execution of\bis delegated to the regex crate as well.That sounds 💯. I can’t use fancy-regex without a named captures API but I greatly look forward to trying it out. 🎉
Yeah, named captures are probably top of the list and not difficult to implement.
Created an issue for this now, if you want to watch: https://github.com/fancy-regex/fancy-regex/issues/34