real-regex
REAL — linear-time (ReDoS-safe) regex engine with an re-compatible API
What it is and what it does
real-regex is a regex engine that replaces Python's standard `re` module with a linear-time implementation backed by a C++20 Thompson NFA simulator. It guarantees that every accepted pattern runs in linear time with no possibility of catastrophic backtracking (ReDoS), while retaining support for bounded lookarounds—a feature that competing linear engines drop to maintain safety. The API mirrors `re` exactly: `compile`, `search`, `match`, `fullmatch`, `findall`, `finditer`, `sub`, `subn`, `split`, and all standard match object methods work as expected.
The trade-off is strictness: patterns using backreferences, conditionals, or certain Unicode properties raise an error rather than falling back silently to backtracking. This is intentional—a compiled pattern is a safety guarantee. You can opt into fallback behavior per call or globally if needed, at the cost of losing the linear-time promise for those patterns. The engine ships as a compiled wheel with no runtime dependencies, and the same C++ library is available to C++ code via a header-only interface.
Use it for:
- Parsing untrusted user input or hostile regex patterns where ReDoS attacks are a concern
- Text extraction and validation in security-sensitive applications where performance must be predictable
- Large-scale log parsing or data processing where regex performance matters and backtracking blowup is unacceptable
- Building tools that accept user-supplied patterns and need to guarantee they won't hang the system
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
A drop-in replacement for Python's `re` module that uses a linear-time regex engine guaranteed safe from ReDoS attacks, while supporting bounded lookarounds that other linear engines omit.
Yes, if you need ReDoS-safe regex with predictable performance and can accept that the project is very new (first release 2026-06-13). The API is familiar, the license is permissive, and there are no known vulnerabilities. Install friction is medium due to compilation, but wheels cover common platforms. Verify production stability and real-world performance for your specific patterns before relying on it in critical systems.
Install
real-regex on PyPI
pip
pip install real-regexuv
uv add real-regexpoetry
poetry add real-regexInstalling real-regex
Before you install
Medium install friction due to compiled wheels for multiple platforms. Active maintenance with release on 2026-08-14; the project is very new (first release 2026-06-13) and has low star count, so production stability is unproven.
License in practice
MIT license permits commercial and private use with minimal restrictions — standard permissive terms.
Quickstart
pip install real-regex
import real as re
m = re.match(r"(\w+)@(\w+)\.(\w+)", "user@example.com")
print(m.group(1), m.group(2), m.group(3))
Requires Python >= 3.10
Verify before relying
- Whether the linear-time guarantee holds for all real-world regex patterns developers actually use
- Performance comparison details beyond the mention that it is faster on most work but slower on some cases
- Maturity and stability of the C++20 engine in production environments
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 0 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 88,057/month — #13,751 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: real_regex-2026.8.15-cp310-abi3-macosx_10_9_x86_64.whl; real_regex-2026.8.15-cp310-abi3-macosx_11_0_arm64.whl; real_regex-2026.8.15-cp310-abi3-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl; real_regex-2026.8.15-cp310-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl; real_regex-2026.8.15-cp310-abi3-musllinux_1_2_aarch64.whl; real_regex-2026.8.15-cp310-abi3-musllinux_1_2_x86_64.whl; real_regex-2026.8.15-cp310-abi3-win32.whl; real_regex-2026.8.15-cp310-abi3-win_amd64.whl
Keywords: regex, regular-expression, redos, linear-time, re
Tags
More Libraries packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
google-re2A drop-in replacement for Python's re module…
permissive · top 5,000 on PyPI
regexA drop-in replacement for Python's standard…
permissive · top 100 on PyPI
regexploitRegexploit analyzes regular expressions to…
permissive · top 15,000 on PyPI
onigurumacffiProvides Python bindings to the Oniguruma regex…
permissive · top 15,000 on PyPI
flpcflpc wraps the Rust regex crate to provide…
permissive · top 5,000 on PyPI
firstReturns the first true value from an iterable,…
permissive · top 15,000 on PyPI
backrefsBackrefs extends Python's re and regex…
permissive · top 5,000 on PyPI
multiregexMatches multiple regex patterns against a…
permissive · top 15,000 on PyPI
regressProvides Python bindings to the Rust regress…
permissive · top 5,000 on PyPI
hyperscanPython bindings for Vectorscan (an open-source…
permissive · top 15,000 on PyPI