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

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.8
File Size Uploaded
real_regex-2026.10.8.tar.gz 672.2 kB Details

Built distributions (wheels)

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

Total release size: 22.9 MB

Release files / real_regex-2026.10.8.tar.gz

Download URL real_regex-2026.10.8.tar.gz
Size 672.2 kB
Tags Source
SHA-256 checksum
How to use checksums
3b12817d28b37d6a54c3ee45a0e863951b1d2bd750c625b6615448af8f922d59
BLAKE2b-256 checksum
How to use checksums
c2531f916f01a8e4f16cb22885f77491e2cf5a7db06cf028bdcb78dde5a5f16a
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 9, 2026.

Transparency log

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

Download URL real_regex-2026.10.8-cp311-abi3-win_amd64.whl
Size 1.1 MB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
a089dd11b5f8151a70d5014ac26c0a800d5ece61d2b234f9f032a233a2a38de5
BLAKE2b-256 checksum
How to use checksums
4ecc02fd59cf86a6beaf3e948d68ad5f8327025af979a1e989ff41e7a244f60c
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 9, 2026.

Transparency log

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

Download URL real_regex-2026.10.8-cp311-abi3-win32.whl
Size 1.1 MB
Tags CPython 3.11 Windows x86-32 abi3
SHA-256 checksum
How to use checksums
b1958848d31c819fa483fb30722bbdb705d1731586989e2c4bfa71afa9148dd4
BLAKE2b-256 checksum
How to use checksums
0f6a152f5975feac99b7ec347e987b5a046b806ea4de1fe1a998f098ddf023f7
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 9, 2026.

Transparency log

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

Download URL real_regex-2026.10.8-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
f1d06428d250edc37d350a337e4d618c850c79dfd4487e492a3592fd6061285b
BLAKE2b-256 checksum
How to use checksums
78477ecf6abceb9d80fbd15955ee65335fbbab10b7fb359e595a86fb0d750f13
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 9, 2026.

Transparency log

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

Download URL real_regex-2026.10.8-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
b8e58d0b86afbea5fc8a0ae767fec780696d14b8d005e7cd671451e81805c1db
BLAKE2b-256 checksum
How to use checksums
12fad8ff34d36d6c34ce676e320c9f7253e96d45343625284df10f2f17bd4651
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 9, 2026.

Transparency log

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

Download URL real_regex-2026.10.8-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
b6694bd6e27d9780e884eae3a96534a84847b33276ba4ae11e96e0936e866af8
BLAKE2b-256 checksum
How to use checksums
1b4a2354eefc3751b7d0044bcff56ce4bd487b08efa26e764e0941e540025798
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 9, 2026.

Transparency log

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

Download URL real_regex-2026.10.8-cp311-abi3-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Size 4.0 MB
Tags CPython 3.11 Linux glibc 2.24+ ARM64 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
4bf46b25ccf83647a8a48cbb8e07c944a03acd520263687656c47db5cddc98d1
BLAKE2b-256 checksum
How to use checksums
371bd815001348583961eedb12ed2c98e7245e202f907af1b31e5dd1d44273cb
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 9, 2026.

Transparency log

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

Download URL real_regex-2026.10.8-cp311-abi3-macosx_11_0_arm64.whl
Size 943.8 kB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
3794fcbe17f7a6aa769095fcc04a6807cb9a3c9a9a95907094cbc7518f47122c
BLAKE2b-256 checksum
How to use checksums
19d491500cae729c51c16c8ba1501be27521376d7840a875f22b042389c45cbf
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 9, 2026.

Transparency log

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

Download URL real_regex-2026.10.8-cp311-abi3-macosx_10_9_x86_64.whl
Size 979.3 kB
Tags CPython 3.11 abi3 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
bc2de17c112c3fbd5284f2c0a923bd300f96fff9c65745ed5e52af86457bb1a9
BLAKE2b-256 checksum
How to use checksums
78b0b776ee9b1363ccf7d7ff2cb4592f1d53814d9d60bce1375036918accc134
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 9, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

2026.10.8 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