Description
RE2 is a regular expression library written in C++ by Google. It is designed as a fast, safe and thread-friendly alternative to the backtracking engines used in PCRE, Perl and Python. Its primary goal is safety: it can handle regular expressions from untrusted users without the risk that a crafted pattern will lock up the program. The README explains that its match time is linear in the length of the input, which is the property that makes it safe for untrusted patterns, and it has been used in production at Google since 2006. Because it does not use backtracking, RE2 does not support some features that backtracking engines offer, such as backreferences, and the README has a syntax section that lists what is supported. The repository includes a C++ API reference and installation instructions, along with contributing guidelines and a security policy. RE2 suits developers who build services that accept patterns or search rules from users, and who need predictable performance.…
Highlights
- Linear-time matching
- Safe for untrusted patterns
- C++ library with an API reference
- Used in production at Google since 2006
Ratings & Reviews
No ratings yet
Be the first to rate Re2.
People also visit

cpp-coding-standards
C++ coding standards based on the C++ Core Guidelines (isocpp.github.io)
Re2 FAQ
What is RE2?
A regular expression library in C++ from Google, designed to be fast and safe.
Why is it safe?
Its match time is linear in the length of the input, so it can handle patterns from untrusted users.
What does it replace?
The backtracking engines used in PCRE, Perl and Python, as an alternative.
Does it support every regex feature?
The README has a syntax section that lists what is supported.
Where is the API?
The README includes a C++ API section and installation instructions.
What are the best Re2 alternatives?
Popular alternatives to Re2 include C2rust, Choose and Frozen. See all Re2 alternatives




