re2
brew install re2
v2025-11-05
BSD-3-Clause
C++ regular expression library with linear-time matching guarantees and memory safety, designed for untrusted input.
Why you might care
RE2 prioritizes safety and predictable performance over feature completeness: it guarantees O(n) match time regardless of regex complexity, preventing catastrophic backtracking and DoS attacks. Use it when parsing untrusted regexes or when you need production-grade safety; it's a runtime dependency for Go (which embeds RE2) and other projects requiring hardened regex handling.
7.2k
30-day installs · #453
21.3k
90-day · #492
118.0k
365-day · #379
9.7k
★ GitHub stars · updated 4mo ago
Runtime dependencies
Build dependencies
Links
- https://github.com/google/re2
- GitHub: google/re2
- Brew formula source: Formula/r/re2.rb
Blurb generated by claude-haiku-4-5 on today.
Raw metadata
{
"aliases": [],
"alternatives": [
"PCRE",
"PCRE2",
"Oniguruma",
"libregex"
],
"build_dependencies": [
"cmake"
],
"categories": [
"library",
"security"
],
"caveats": null,
"conflicts_with": [],
"dependencies": [
"abseil"
],
"deprecated": 0,
"deprecation_reason": null,
"desc": "Alternative to backtracking PCRE-style regular expression engines",
"disable_reason": null,
"disabled": 0,
"enrichment_fetched_at": "2026-06-20T23:40:52+00:00",
"first_seen": "2026-06-20T23:34:18+00:00",
"full_name": "re2",
"github_default_branch": "main",
"github_last_commit_at": "2026-01-22T23:28:54Z",
"github_readme_excerpt": "# RE2, a regular expression library\n\nRE2 is an efficient, principled regular expression library\nthat has been used in production at Google and many other places\nsince 2006.\n\n_**Safety is RE2\u0027s primary goal.**_\n\nRE2 was designed and implemented with an explicit goal of being able\nto handle regular expressions from untrusted users without risk.\nOne of its primary guarantees is that the match time is linear in the\nlength of the input string. It was also written with production concerns in mind:\nthe parser, the compiler and the execution engines limit their memory usage\nby working within a configurable budget\u2014failing gracefully when exhausted\u2014and\nthey avoid stack overflow by eschewing recursion.\n\nIt is not a goal to be faster than all other engines under all circumstances.\nAlthough RE2 guarantees a running time that is asymptotically linear in\nthe length of the input, more complex expressions may incur larger constant factors;\nlonger expressions increase the overhead required to handle those expressions safely.\nIn a sense, RE2 is pessimistic where a backtracking engine is optimistic:\nA backtracking engine tests each alternative sequentially, making it fast when the first alternative is common.\nBy contrast RE2 evaluates all alternatives in parallel, avoiding the performance penalty for the last alternative,\nat the cost of some overhead. This pessimism is what makes RE2 secure.\n\nIt is also not a goal to implement all of the features offered by Perl, PCRE and other engines.\nAs a matter of principle, RE2 does not support constructs for which only backtracking solutions are known to exist.\nThus, backreferences and look-around assertions are not supported.\n\nFor more information, please refer to Russ Cox\u0027s articles on regular expression theory and practice:\n\n* [Regular Expression Matching Can Be Simple And Fast](https://swtch.com/~rsc/regexp/regexp1.html)\n* [Regular Expression Matching: the Virtual Machine Approach](https://swtch.com/~rsc/regexp/regexp2.html)\n* [Regular Expres",
"github_repo": "google/re2",
"github_stars": 9707,
"github_topics": [],
"homepage": "https://github.com/google/re2",
"homepage_og_description": null,
"homepage_og_image": null,
"homepage_title": null,
"installs_30d": 7193,
"installs_365d": 117973,
"installs_90d": 21286,
"keg_only": 0,
"keg_only_reason": null,
"last_seen": "2026-06-20T23:34:18+00:00",
"license": "BSD-3-Clause",
"llm_generated_at": "2026-06-20T23:44:59+00:00",
"llm_model": "claude-haiku-4-5",
"name": "re2",
"oldnames": [],
"one_liner": "C++ regular expression library with linear-time matching guarantees and memory safety, designed for untrusted input.",
"optional_dependencies": [],
"rank_30d": 453,
"rank_365d": 379,
"rank_90d": 492,
"raw_hash": "f96ff491af199493",
"recommended_dependencies": [],
"revision": 0,
"ruby_source_path": "Formula/r/re2.rb",
"tap": "homebrew/core",
"test_dependencies": [],
"uses_from_macos": [],
"version_head": "HEAD",
"version_stable": "2025-11-05",
"versioned_formulae": [],
"why_use_this": "RE2 prioritizes safety and predictable performance over feature completeness: it guarantees O(n) match time regardless of regex complexity, preventing catastrophic backtracking and DoS attacks. Use it when parsing untrusted regexes or when you need production-grade safety; it\u0027s a runtime dependency for Go (which embeds RE2) and other projects requiring hardened regex handling."
}