A Rust regular expression library with guaranteed linear time matching using finite automata.
regex is a regular expression library for Rust that provides fast, safe pattern matching with guaranteed linear time complexity. It implements regex searches using finite automata, ensuring predictable performance even with untrusted patterns. The library supports Unicode by default and offers both string and byte-oriented matching APIs.
Rust developers who need reliable and performant text processing, pattern matching, or data validation in their applications. It's particularly valuable for those processing untrusted input where predictable performance is critical.
Developers choose regex for its strong performance guarantees, safety in handling untrusted patterns, and comprehensive feature set including Unicode support and multiple matching strategies. Its linear time complexity prevents catastrophic backtracking, making it more secure and predictable than many other regex engines.
An implementation of regular expressions for Rust. This implementation uses finite automata and guarantees linear time matching on all inputs.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
All searches have worst-case O(m*n) complexity, preventing exponential blowup and ensuring predictable performance with untrusted inputs, as stated in the README.
Unicode is enabled by default, with options to disable it for byte-oriented matching via regex::bytes::Regex, making it versatile for international text and binary data.
RegexSet allows matching multiple regular expressions in a single scan, optimizing performance for sets of patterns, as demonstrated in the usage examples.
Exposes regex-automata for advanced customization, enabling fine-tuned control over matching engines beyond the simple main API.
Omits advanced features like look-around and backreferences to maintain performance guarantees, which can be a deal-breaker for users needing complex regex patterns from other engines.
Compiling a regex can take microseconds to milliseconds, making it inefficient for dynamic patterns that change often, as warned in the README's anti-pattern section.
Accessing advanced features requires diving into regex-automata, which has a steeper learning curve and more verbose API compared to the straightforward main crate.