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.

Release files for real-regex 2026.9.5

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.9.5
File Size Uploaded
real_regex-2026.9.5.tar.gz 679.3 kB Details

Built distributions (wheels)

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

Total release size: 19.3 MB

Release files / real_regex-2026.9.5.tar.gz

Download URL real_regex-2026.9.5.tar.gz
Size 679.3 kB
Tags Source
SHA-256 checksum
How to use checksums
85254e1c69f9e3143e1f69294a3704ec7600eb062f14162ab91bb80f0ddce8b2
BLAKE2b-256 checksum
How to use checksums
cb6c418eba5aea3d06a8de666a0ba4163de24e78ee5ad9182b495923a3511bb2
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 Sep 9, 2026.

Transparency log

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

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

Transparency log

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

Download URL real_regex-2026.9.5-cp311-abi3-win32.whl
Size 1.0 MB
Tags CPython 3.11 Windows x86-32 abi3
SHA-256 checksum
How to use checksums
698b3070a657b5fcac19704aef98f857dadbf01ef6fbc82e04670f6b54a4fd5b
BLAKE2b-256 checksum
How to use checksums
fb207ebdf6c7d2be7edb940385f4c8114a4e1b1c2934117586ea7516054ebef9
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 Sep 9, 2026.

Transparency log

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

Download URL real_regex-2026.9.5-cp311-abi3-musllinux_1_2_x86_64.whl
Size 4.2 MB
Tags CPython 3.11 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
91bf8c8d95bd669e65aea992f3d92a9aec16ba3b58610d3379c61c1faaf591ef
BLAKE2b-256 checksum
How to use checksums
6fba2090bd4a88570d5646ac70e63639ec6254117793f8e2b733c198c66e7440
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 Sep 9, 2026.

Transparency log

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

Download URL real_regex-2026.9.5-cp311-abi3-musllinux_1_2_aarch64.whl
Size 4.1 MB
Tags CPython 3.11 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
b7ffdb9a11b41ef3fef009c32c13217df13536cd59d86a9917486f43ecdbe2aa
BLAKE2b-256 checksum
How to use checksums
409f1eebc0cd0611c1528b442e5095e3be25424ad23b34f530fad7d84eb2942e
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 Sep 9, 2026.

Transparency log

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

Download URL real_regex-2026.9.5-cp311-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 3.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
08cd8008b7d5845d839c3b858ffa22bb7d85532d798f91ceb27a6bd6783c459f
BLAKE2b-256 checksum
How to use checksums
6685e5bfeb199df073dec06b70eb9f3c0662335c448a8a825d0b26279f34955d
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 Sep 9, 2026.

Transparency log

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

Download URL real_regex-2026.9.5-cp311-abi3-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Size 3.2 MB
Tags CPython 3.11 Linux glibc 2.24+ ARM64 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
db2e3b9d5ebc39eb079c7d7894147f15999c5593d9b3873cd3309fdffb303a3e
BLAKE2b-256 checksum
How to use checksums
ed770a9f22538654668464bbe191258224194d03438c92163c912f2299078230
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 Sep 9, 2026.

Transparency log

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

Download URL real_regex-2026.9.5-cp311-abi3-macosx_11_0_arm64.whl
Size 887.4 kB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
48932fa77173f1326ba7746513d4b1f5795175944d369083bcac2db26c286cd4
BLAKE2b-256 checksum
How to use checksums
333d18e7f14f1fb86fecab02b09ca1a78ec65cf1b1459b377174163256f9fb31
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 Sep 9, 2026.

Transparency log

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

Download URL real_regex-2026.9.5-cp311-abi3-macosx_10_9_x86_64.whl
Size 904.2 kB
Tags CPython 3.11 abi3 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
992bb31e746f36c9d44f0dbe1cca2772b0d619a1bf635d5fabd636464746a683
BLAKE2b-256 checksum
How to use checksums
ddefef4d024df685a128c36a3f9391d4764569f1226df04ff487fde4420636ee
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 Sep 9, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

2026.9.5 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