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

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.11
File Size Uploaded
real_regex-2026.10.11.tar.gz 681.5 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for real-regex 2026.10.11
File
real_regex-2026.10.11-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details
real_regex-2026.10.11-cp311-abi3-win32.whl CPython 3.11 abi3 Windows x86-32 Details
real_regex-2026.10.11-cp311-abi3-musllinux_1_2_x86_64.whl CPython 3.11 abi3 Linux musl 1.2+ x86-64 Details
real_regex-2026.10.11-cp311-abi3-musllinux_1_2_aarch64.whl CPython 3.11 abi3 Linux musl 1.2+ ARM64 Details
real_regex-2026.10.11-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.11-cp311-abi3-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl CPython 3.11 abi3 Linux glibc 2.24+ ARM64, Linux glibc 2.28+ ARM64 Details
real_regex-2026.10.11-cp311-abi3-macosx_11_0_arm64.whl CPython 3.11 abi3 macOS 11.0+ ARM64 Details
real_regex-2026.10.11-cp311-abi3-macosx_10_9_x86_64.whl CPython 3.11 abi3 macOS 10.9+ x86-64 Details

Total release size: 23.2 MB

Release files / real_regex-2026.10.11.tar.gz

Download URL real_regex-2026.10.11.tar.gz
Size 681.5 kB
Tags Source
SHA-256 checksum
How to use checksums
78e51598d03fd7b07ca8edc1c0de8c3216b8851892dece59e2006ac5ce02c140
BLAKE2b-256 checksum
How to use checksums
79fc26c3ba88efb1eb36ac09cdcec60f3cff0f24e9008c10099bc48d5e695723
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 11, 2026.

Transparency log

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

Download URL real_regex-2026.10.11-cp311-abi3-win_amd64.whl
Size 1.1 MB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
fbb67f3e87a8704d71855936ccc0ee72eb9a4bfa9fb791870ac45e4824db0479
BLAKE2b-256 checksum
How to use checksums
e81ab13b727a0d71b6c82d82468e0689e648b7a870c78e0e5ffea2f7955027a8
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 11, 2026.

Transparency log

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

Download URL real_regex-2026.10.11-cp311-abi3-win32.whl
Size 1.1 MB
Tags CPython 3.11 Windows x86-32 abi3
SHA-256 checksum
How to use checksums
98143fa194844705621617edbd7978df35aef90c52c467feff4d3749fa7a7611
BLAKE2b-256 checksum
How to use checksums
ea85839f19783d0fc977c7ac441afb6bc162cc7ed47871ea187924d8650b8fb4
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 11, 2026.

Transparency log

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

Download URL real_regex-2026.10.11-cp311-abi3-musllinux_1_2_x86_64.whl
Size 5.1 MB
Tags CPython 3.11 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
64a2011756b61ce7d39925a1754510a2e8eb319897e43803eac4744d8e298398
BLAKE2b-256 checksum
How to use checksums
4d2ed97203e729d7ba752f9b7490178a10abe763d2472489cc0033a86db03467
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 11, 2026.

Transparency log

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

Download URL real_regex-2026.10.11-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
0291e2ff5de037bda6b9b4a6c7e949fd7fe7bac50cc4863b27743109be34f11c
BLAKE2b-256 checksum
How to use checksums
3050a357fbb338a80c8c1c6a706a0c685fe4e34ac63b1a69efd8fc1f762b3d45
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 11, 2026.

Transparency log

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

Download URL real_regex-2026.10.11-cp311-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 4.1 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
5ce25e78effe621fd211e29268ca8fb6471bda7b72cad3ae2b2df7d3d786106c
BLAKE2b-256 checksum
How to use checksums
861117beaa8a7d31079a336d2c9ba4618bb921811cd6ad5872bf1b22935b6165
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 11, 2026.

Transparency log

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

Download URL real_regex-2026.10.11-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
3437f8e12ff538b79843e22c5adcde67665451afc1d0bebef375350ba9a6b2b3
BLAKE2b-256 checksum
How to use checksums
e3c7de957c316e50a90a4ce290e66521f61d15512de8d44d0b7d61e7fe66eb6a
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 11, 2026.

Transparency log

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

Download URL real_regex-2026.10.11-cp311-abi3-macosx_11_0_arm64.whl
Size 958.6 kB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
c09c3bab55fbf287b2ffe25312d8aed4539a8dc9c76ace05d04fbb3dfd4960c5
BLAKE2b-256 checksum
How to use checksums
b997ee24c19fe455ebd0eb2c793e339b996b724f2e54129307cd3699400b8493
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 11, 2026.

Transparency log

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

Download URL real_regex-2026.10.11-cp311-abi3-macosx_10_9_x86_64.whl
Size 992.2 kB
Tags CPython 3.11 abi3 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
108e1194b149fd738aa3ab1e32f806113752d189c26c3356fdfb54172d22bc41
BLAKE2b-256 checksum
How to use checksums
9a6eb64d48a14583e2b4ea54e09161b1bf11462ce76574eda1529edf3997dad8
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 11, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

2026.10.11 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