skillfed

real-regex

REAL — linear-time (ReDoS-safe) regex engine with an re-compatible API

real-regex v2026.8.15 88.1K downloads/30d#13,751 on PyPI2
Permissive license MIT Active released

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-regex

uv

uv add real-regex

poetry

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 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

Development Status :: 4 - BetaIntended Audience :: DevelopersOperating System :: OS IndependentProgramming Language :: C++Programming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyTopic :: Software Development :: LibrariesTopic :: Text Processing

Tags

redos-safe regex enginelinear-time pattern matchingre module replacementcatastrophic backtracking preventionbounded lookaround regexsafe regular expressionsthompson nfa regex
security-focusedperformance-predictable

More Libraries packages