--- id: google-re2 version: "1.1.20251105" license: unclear license_treatment: permissive maintenance: aging --- # google-re2 — RE2 Python bindings License: permissive · Maintenance: aging · Downloads: 16.1M/mo ## What it is and what it does google-re2 wraps Google's RE2 regular expression engine as a Python module that mimics the standard re module's interface. It trades support for some advanced PCRE features—like backreferences and lookaround assertions—for guaranteed linear-time matching and immunity to catastrophic backtracking, making it suitable for processing untrusted input or patterns where performance predictability matters. The package is a compiled C++ extension, so installation uses prebuilt wheels when available. Its API closely mirrors Python's re module, but with notable differences: pattern and input strings don't need to match types (str is encoded to UTF-8), the Options class replaces re flags with RE2's own options, and error reporting is minimal. The description notes several syntax gotchas relative to Python's re—most notably that \Z must be rewritten as \z. Use it for: - Processing untrusted regex patterns or input where catastrophic backtracking is a security concern - High-throughput text processing where predictable linear-time performance is required - Migrating from re to a safer engine when PCRE features like backreferences are not needed - Building systems that need consistent regex behavior across different input types without type coercion ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. A drop-in replacement for Python's re module that uses Google's RE2 engine for pattern matching, trading some PCRE features for guaranteed linear-time performance. Yes, if you need predictable regex performance and can accept RE2's syntax limitations. The permissive license and active repository are favorable. Medium install friction (system libraries required) and aging maintenance status (282 days since release) are minor concerns; the underlying RE2 engine is mature and the package has no known vulnerabilities. Not suitable if your patterns rely on backreferences, lookarounds, or other PCRE-only features. ## Install pip install google-re2 uv add google-re2 poetry add google-re2 ## Installing google-re2 Before you install: Medium install friction: precompiled wheels are available for current Python versions on macOS, Linux, and Windows, but building from source requires RE2 and pybind11 system libraries. The package is aging (282 days since last release) but the underlying repository remains active. License in practice: Permissive license (BSD) means you can use, modify, and distribute this package with minimal restrictions, though you should include the license notice in distributions. Quickstart: import re2 pattern = re2.compile(r'\w+') match = pattern.search('hello world') if match: print(match.group()) Requires RE2 library and pybind11 to be installed on your system before installation; precompiled wheels available for Python 3.9+ on common platforms. Verify before relying: - Performance characteristics compared to standard re module in typical workloads - Compatibility with third-party libraries that expect the standard re module API - Current status of Windows build support (documentation notes it has not been tested) ## Package facts - License: not declared (permissive) - Python support: supports_current - Install friction: medium - Maintenance: aging - Downloads: 16.1M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags re2 regex engine python, linear time pattern matching, google re2 bindings, safe regex engine, re module replacement, regex-engine, performance-predictable, c-extension [View on SkillFed](https://skillfed.io/packages/google-re2) · [View on PyPI](https://pypi.org/project/google-re2/)