A Rust regex library with hybrid NFA/backtracking engine for advanced features like look-around and backreferences.
fancy-regex is a Rust library for regular expressions that supports advanced features like look-around and backreferences through a hybrid implementation. It combines backtracking for these "fancy" features with delegation to a high-performance NFA engine (the Rust regex crate) for parts of expressions that don't require them, aiming to provide both rich functionality and good performance.
Rust developers needing advanced regex features (like look-around or backreferences) for tasks such as syntax highlighting, text processing, or compatibility with Oniguruma-based grammars, where purely NFA-based engines are insufficient.
Developers choose fancy-regex because it uniquely offers advanced regex features in Rust without the exponential worst-case performance of pure backtracking engines, by intelligently delegating to the efficient regex crate where possible, and providing Oniguruma syntax compatibility for editor grammars.
Rust library for regular expressions using "fancy" features like look-around and backreferences. Has a mode which aims to be compatible with Oniguruma syntax.
Supports look-around and backreferences, enabling complex patterns like those used in TextMate syntax definitions, as shown in the README's example of capturing Rust raw strings with r(#*)".*?"\1.
Delegates to the Rust regex crate for NFA-based matching where possible, minimizing backtracking and aiming for linear-time performance, as detailed in the theory section on bottom-up and top-down analysis.
Offers a mode compatible with Oniguruma syntax, making it suitable for porting editor grammars from Sublime Text or Atom, as mentioned in the philosophy for syntax highlighting.
Provides a web-based playground for testing and exploring regexes with advanced features, linked in the README for easy experimentation and debugging.
The README explicitly states that backreferences at recursion levels and optimizations are currently missing, limiting functionality for advanced or edge-case regex patterns.
For regexes with fancy features, fancy-regex gives no guarantees against exponential blowup, posing a denial-of-service risk if patterns are attacker-controlled, as warned in the 'A warning about worst-case performance' section.
Still in development with ongoing changes, which might lead to breaking updates or incomplete documentation compared to more mature libraries like the regex crate.
fancy-regex is an open-source alternative to the following products:
rga: ripgrep, but also search in PDFs, E-Books, Office documents, zip, tar.gz, etc.
A polyglot document intelligence framework with a Rust core. Extract text, metadata, images, and structured information from PDFs, Office documents, images, and 97+ formats. Available for Rust, Python, Ruby, Java, Go, PHP, Elixir, C#, R, C, TypeScript (Node/Bun/Wasm/Deno)- or use via CLI, REST API, or MCP server.
A command-line tool and Rust library with Python bindings for generating regular expressions from user-provided test cases
Melody is a language that compiles to regular expressions and aims to be more readable and maintainable
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.