A fast, safe, thread-friendly regular expression library with linear-time matching guarantees, designed for production use.
RE2 is an efficient, principled regular expression library developed at Google and used in production since 2006. It provides a safe alternative to backtracking engines by guaranteeing linear-time matching and limiting memory usage, making it suitable for handling expressions from untrusted users.
Developers building systems that need to safely process regular expressions from untrusted sources, such as web services, security tools, or production applications where predictable performance and memory safety are critical.
Developers choose RE2 over alternatives because it prioritizes safety and predictable performance, guaranteeing linear-time matching and configurable memory limits to avoid exponential backtracking and stack overflow, unlike engines that support backtracking-dependent features like backreferences.
RE2 is a fast, safe, thread-friendly alternative to backtracking regular expression engines like those used in PCRE, Perl, and Python. It is a C++ library.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Ensures match time is linear in input length, preventing exponential backtracking and making it safe for untrusted user inputs.
Operates within configurable memory limits and avoids recursion, ensuring no stack overflow and graceful failure under memory constraints.
Designed for safe concurrent use, making it ideal for multi-threaded environments in production systems.
Supports POSIX and most Perl syntax, excluding only backtracking-dependent features, allowing developers to use familiar patterns safely.
Does not support backreferences, look-around assertions, or other constructs that require backtracking, which are common in advanced regex use cases.
Uses pessimistic parallel evaluation, which can incur overhead for simpler expressions compared to optimistic backtracking engines, potentially slowing down common matches.
Requires C++17, the Abseil library, and additional dependencies for tests, complicating setup compared to more integrated regex solutions.
Syntax is an open-source alternative to the following products:
The Perl regex engine is the regular expression processing component built into the Perl programming language, known for its powerful pattern-matching capabilities.
The Python regex engine is the built-in regular expression module (re) in Python that provides pattern matching and text manipulation capabilities using regular expressions.
A library of Perl-compatible regular expression functions for C and C++ programming languages, widely used for pattern matching.