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

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.2
File Size Uploaded
real_regex-2026.10.2.tar.gz 781.3 kB Details

Built distributions (wheels)

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

Total release size: 23.5 MB

Release files / real_regex-2026.10.2.tar.gz

Download URL real_regex-2026.10.2.tar.gz
Size 781.3 kB
Tags Source
SHA-256 checksum
How to use checksums
5af542252dfe78174c8e4c6fcf7e8e40ec85024a6f2564ee4f9caa7175162c97
BLAKE2b-256 checksum
How to use checksums
d6890608474c802d7658c674c95bbdac861c17c1a8e2fc6f84244f066b50a630
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 3, 2026.

Transparency log

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

Download URL real_regex-2026.10.2-cp311-abi3-win_amd64.whl
Size 1.2 MB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
521ff04716c27afd1f8306b68b716e52f02c69e31a91e83bdc21ab1efa4079e4
BLAKE2b-256 checksum
How to use checksums
af115c952b6ac7f03c31dca181d277aa7cefcaec28c3446ff014027d17dc10e2
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 3, 2026.

Transparency log

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

Download URL real_regex-2026.10.2-cp311-abi3-win32.whl
Size 1.2 MB
Tags CPython 3.11 Windows x86-32 abi3
SHA-256 checksum
How to use checksums
8e86de52204fc5858272acde62efdbacea0860e9b648f26cafecd9e05fafe23a
BLAKE2b-256 checksum
How to use checksums
3fc5d49278bf5e2c1efacad5b51a0d5c746bc9d9607c3e7808a4b51617b6eb83
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 3, 2026.

Transparency log

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

Download URL real_regex-2026.10.2-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
b27aa89d0edbd3234ce39df8723171cb37c67bf856269275bd8fd02ccccebfed
BLAKE2b-256 checksum
How to use checksums
aa3600a8ca00aa4bf7a06ffff5a09c3c5329bb2545c18546ddfa55ae98159d08
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 3, 2026.

Transparency log

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

Download URL real_regex-2026.10.2-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
c1877deb735bef5429550f0a79a968e85b4a5877964215463ee5e8534b2a7182
BLAKE2b-256 checksum
How to use checksums
62097df76b4bced0bd34d2da75530866b53707d5e5edbf2bef396636a448a47d
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 3, 2026.

Transparency log

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

Download URL real_regex-2026.10.2-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
d784fd53969ad2269938c44559de00eafb4655419a5e2877a0f9aae9c3ab89d7
BLAKE2b-256 checksum
How to use checksums
bfa0ca218f3ff357dbf9ed0a00d0035ef1ba11fd5a117f5237cf39d02b03e5bc
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 3, 2026.

Transparency log

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

Download URL real_regex-2026.10.2-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
9d5f63f705898c192e4276d3d27872a970d5ba36f12b6ebfcf692b4b9884ebe7
BLAKE2b-256 checksum
How to use checksums
0650ef9804b49d475c167e10e1c7e1b6d8ce2cbab1e0f9985d1b015ede18cb92
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 3, 2026.

Transparency log

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

Download URL real_regex-2026.10.2-cp311-abi3-macosx_11_0_arm64.whl
Size 1.1 MB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
0fb372f0717d7a9a2a1207bdd450efbde0c504d6c2589ffaf0c817ab910913e8
BLAKE2b-256 checksum
How to use checksums
a9edc5bf3050a5754322c827a602514e6ab741c0aef44217805904a75b2d1352
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 3, 2026.

Transparency log

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

Download URL real_regex-2026.10.2-cp311-abi3-macosx_10_9_x86_64.whl
Size 1.1 MB
Tags CPython 3.11 abi3 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
886f402bfea4253d6d38b148101505eded6e020732e2d574c44770559b55e9a8
BLAKE2b-256 checksum
How to use checksums
0bc7ed3df68219f6fd065d62255245d10e96e07fb712fa6e9de64311e647f663
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 3, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

2026.10.2 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