Jump to content

RE2 (software)

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by Wikieditoroftoday (talk | contribs) at 22:12, 21 June 2015 (Windows port: Removed unsourced and confusingly phrased bit). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

RE2
Original author(s)Google
Repository
Written inC++
Operating systemCross-platform
TypePattern matching library
LicenseBSD
Websitegithub.com/google/re2

RE2 is a software library for regular expressions via a finite-state machine using automata theory, in contrast to almost all other regular expression libraries, which use backtracking implementations. It provides a C++ interface.

RE2 was implemented and is used by Google.

Comparison to PCRE

"RE2" compares to Perl Compatible Regular Expressions (PCRE) in performance, but greatly exceeds PCRE for regular expression operators like ("|") (boolean "or").

RE2 does not support back-references, which cannot be implemented efficiently. It is also slightly slower than PCRE for parenthetic capturing operations, but is much faster for matching in general.

PCRE can use a large recursive stack and have exponential runtime on certain patterns. RE2 uses a fixed stack and guarantees that run-time increases linearly (not exponentially) with the size of the input. The maximum memory allocated with RE2 can be configured if you have good knowledge of the workings of its code.

Google's RE2 has a slightly smaller set of features than PCRE, but has very predictable run-time and a maximum memory allotment, making it suitable for use in server applications which require precise boundaries on memory usage and computational time. PCRE, on the other hand, has almost all of the features that a regular expression library can have, but has unpredictable run-time and memory usage and can grow unbounded.

Windows port

RE2 by Google is designed for the Linux operating system, and does not run natively on Microsoft Windows. A port to Windows is available.[1] The port aims to change as little code as possible from the original project and compiles with Microsoft C++ Compilers.

See also

References

  1. ^ "re2win: an efficient, principled regular expression library (Windows port)". Google Project Hosting. Google. Retrieved 2012-05-10.