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.
Browse cluster: OCaml Systems and Utilities →RE2 is a regular expression library implemented in C++ that prioritizes safety and efficiency as an alternative to backtracking engines like those in PCRE, Perl, and Python. Developed and used in production at Google since 2006, RE2 guarantees linear match time relative to input string length and is designed to safely handle regular expressions from untrusted users without risk of exponential runtime or stack overflow. The library is built with C++17 and depends on the Abseil library, with optional support for GoogleTest, Benchmark, and ICU for extended Unicode properties. Beyond its native C++ API, RE2 provides an official Python wrapper available on PyPI as `google-re2` and numerous unofficial wrappers for languages including D, Erlang, Node.js, OCaml, Perl, R, Ruby, and WebAssembly, as well as ports to Java and JavaScript.