--- id: real-regex version: "2026.8.15" license: MIT license_treatment: permissive maintenance: active --- # real-regex — REAL — linear-time (ReDoS-safe) regex engine with an re-compatible API License: permissive · Maintenance: active · Downloads: 88.1K/mo ## 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 above — 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 pip install real-regex uv add real-regex poetry add real-regex ## Installing 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_current - Install friction: medium - Maintenance: active - Downloads: 88.1K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags redos-safe regex engine, linear-time pattern matching, re module replacement, catastrophic backtracking prevention, bounded lookaround regex, safe regular expressions, thompson nfa regex, security-focused, performance-predictable [View on SkillFed](https://skillfed.io/packages/real-regex) · [View on PyPI](https://pypi.org/project/real-regex/)