Skip to main content

real-regex

A drop-in replacement for Python's re, backed by a linear-time, ReDoS-safe C++20 engine — with bounded lookarounds that the other linear-time engines (RE2, Rust) don't have.

pip install real-regex

Drop-in for re

Import it as re and use the API you already know — compile, search, match, fullmatch, findall, finditer, sub, subn, split, and Match.group / groups / groupdict / span / start / end:

import real as re

m = re.match(r"(\w+)@(\w+)\.(\w+)", "user@example.com")
m.group(1), m.group(2), m.group(3)          # ('user', 'example', 'com')

re.findall(r"\d+", "a1 b22 c333")            # ['1', '22', '333']
re.sub(r"\s+", "_", "a  b   c")              # 'a_b_c'

Flags work the same: re.I, re.M, re.S, re.X, re.A. Unicode \w \d \s \b and IGNORECASE case-folding follow re in text mode.

Why replace re

  • No ReDoS. re (like every backtracking engine) blows up on patterns like (a+)+b against a hostile input — seconds, then minutes. real-regex is a Thompson NFA simulation: linear time, always, no catastrophic backtracking, ever.
  • Bounded lookarounds, still linear. (?=…) (?!…) (?<=…) (?<!…) — including variable-width lookbehind — match without backtracking. RE2 and Rust drop lookarounds to stay safe; real-regex keeps them.
  • Faster than re on most work — the measured multiples (geometric mean, per-case wins and the two accepted losses) live in docs/BENCHMARKS.md §B. Sparse scans, multiline anchors and capture-dense extraction lead; a couple of high-volume split/tiny-anchored cases stay slower (CPython's C engine wins there). It is not the fastest engine at raw throughput — it is the safe one that is also quick.

Not re, on purpose

Strict by default — every accepted pattern is guaranteed linear. The unsupported constructs (backreferences, conditionals, non-binary Unicode properties like \p{Bidi_Class=L}) raise real.error rather than silently falling back to a backtracking engine, so a compiled pattern is a ReDoS-safety guarantee, not a maybe. (\p{L} / \p{sc=Greek} / \p{scx=Grek} / \p{Alphabetic} — General_Category, Script, Script_Extensions and the standard binary properties — are supported, a superset of stdlib re.) Opt into delegating those to the standard library re per call with real.compile(pat, fallback=True) (or module-wide with real.fallback = True) — it may accept them, at the cost of the linear-time guarantee for that pattern; Pattern.engine ("real" or "re") always tells you which backend you got. A few semantics differ deliberately (e.g. a nullable loop's final empty capture). Full list: Differences from Python re.

The wheel also ships the header-only C++ library — real.get_include() returns its path, so the same engine is available to C++ via #include <real/real.hpp>. Source, benchmarks and the C++ API: https://github.com/RECHE23/real-regex.

Metadata

Release files for real-regex 2026.10.17

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for real-regex 2026.10.17
File Size Uploaded
real_regex-2026.10.17.tar.gz 687.6 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for real-regex 2026.10.17
File
real_regex-2026.10.17-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details
real_regex-2026.10.17-cp311-abi3-win32.whl CPython 3.11 abi3 Windows x86-32 Details
real_regex-2026.10.17-cp311-abi3-musllinux_1_2_x86_64.whl CPython 3.11 abi3 Linux musl 1.2+ x86-64 Details
real_regex-2026.10.17-cp311-abi3-musllinux_1_2_aarch64.whl CPython 3.11 abi3 Linux musl 1.2+ ARM64 Details
real_regex-2026.10.17-cp311-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl CPython 3.11 abi3 Linux glibc 2.28+ x86-64, Linux glibc 2.24+ x86-64 Details
real_regex-2026.10.17-cp311-abi3-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl CPython 3.11 abi3 Linux glibc 2.28+ ARM64, Linux glibc 2.24+ ARM64 Details
real_regex-2026.10.17-cp311-abi3-macosx_11_0_arm64.whl CPython 3.11 abi3 macOS 11.0+ ARM64 Details
real_regex-2026.10.17-cp311-abi3-macosx_10_9_x86_64.whl CPython 3.11 abi3 macOS 10.9+ x86-64 Details

Total release size: 23.3 MB

Release files / real_regex-2026.10.17.tar.gz

Download URL real_regex-2026.10.17.tar.gz
Size 687.6 kB
Tags Source
SHA-256 checksum
How to use checksums
9a2d7e36e28d33582ba872058c876e0841b0340f34d8c1acf8ba09d59be76c9d
BLAKE2b-256 checksum
How to use checksums
d4530afcac313e2700ba1dd8505af41e35a8accc8fd9b04eafdbb8f9d5233ae7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.

Transparency log

Release files / real_regex-2026.10.17-cp311-abi3-win_amd64.whl

Download URL real_regex-2026.10.17-cp311-abi3-win_amd64.whl
Size 1.1 MB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
2406b043e17850af1c76e95e0eba4e88292704ab2b65811e135cad1dc2fd4caf
BLAKE2b-256 checksum
How to use checksums
9a97e1a8d5a0c06d30c39d85ceb00b9604ca6b7d9438d6acd5f742e0e27fe400
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.

Transparency log

Release files / real_regex-2026.10.17-cp311-abi3-win32.whl

Download URL real_regex-2026.10.17-cp311-abi3-win32.whl
Size 1.1 MB
Tags CPython 3.11 Windows x86-32 abi3
SHA-256 checksum
How to use checksums
5de1b1551659b52d1414b1485567bf58efd0b8b2ae34cbd13a1a3b8df66ed790
BLAKE2b-256 checksum
How to use checksums
8b14500bf1cd0e5beae2a64dbf2a01aa5ef27e69be47356e8fd5be43f38bf06b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.

Transparency log

Release files / real_regex-2026.10.17-cp311-abi3-musllinux_1_2_x86_64.whl

Download URL real_regex-2026.10.17-cp311-abi3-musllinux_1_2_x86_64.whl
Size 5.2 MB
Tags CPython 3.11 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
60e1dc5e364aea434979e74afa97cb5ab729bb563cd2f397fa702285d9952664
BLAKE2b-256 checksum
How to use checksums
4a6cdb6f9247169036d102e146b9f6af8fdf3a82ee5240e7473445531a070d42
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.

Transparency log

Release files / real_regex-2026.10.17-cp311-abi3-musllinux_1_2_aarch64.whl

Download URL real_regex-2026.10.17-cp311-abi3-musllinux_1_2_aarch64.whl
Size 5.0 MB
Tags CPython 3.11 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
a9e500a31a52641da46fde4ef0d4fed0d0fafa5ba86172855d0f278f442af8d8
BLAKE2b-256 checksum
How to use checksums
f90ab538a56b14708de564c327fcd79fdd9bd5a05a73edd9f5eaf0b9f78e585e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.

Transparency log

Release files / real_regex-2026.10.17-cp311-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL real_regex-2026.10.17-cp311-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 4.2 MB
Tags CPython 3.11 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
2f5b3261cde09e079ec292c55154e363c204c3e033fb80e6ff971b9cbe1384e6
BLAKE2b-256 checksum
How to use checksums
eaba76d0104090c2e3e36657d62e89d1fd2a3af702bf45533ab15603ffa92dc1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.

Transparency log

Release files / real_regex-2026.10.17-cp311-abi3-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl

Download URL real_regex-2026.10.17-cp311-abi3-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Size 4.1 MB
Tags CPython 3.11 Linux glibc 2.24+ ARM64 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
f5c49f8be8b1027c11b892a0ac9741cef1eba29a5d1484ed28f57c09f3234fe9
BLAKE2b-256 checksum
How to use checksums
f0d4ef966685bd81135ee238ce95eeffa46627e9c3910fb9a0e636ed9bbd60fe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.

Transparency log

Release files / real_regex-2026.10.17-cp311-abi3-macosx_11_0_arm64.whl

Download URL real_regex-2026.10.17-cp311-abi3-macosx_11_0_arm64.whl
Size 964.9 kB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
30c5b63edce734f04ee9a480b8febd7e44151f55407e74f9967152b44896eee2
BLAKE2b-256 checksum
How to use checksums
4e0f83783223abc5782abd85d5bc756144a7a1290f0981680968abfc1df88440
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.

Transparency log

Release files / real_regex-2026.10.17-cp311-abi3-macosx_10_9_x86_64.whl

Download URL real_regex-2026.10.17-cp311-abi3-macosx_10_9_x86_64.whl
Size 999.4 kB
Tags CPython 3.11 abi3 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
907d1c1caac8795e7d11c0c6860a94f4b8c31de7d984ec9f92fba517e28d7123
BLAKE2b-256 checksum
How to use checksums
e16189a4c8ceee43253f5fd492ce51e2b8492917df1df1356e0ccbc935c31caa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

2026.10.17 This release

9 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page