Skip to main content

REAL — linear-time (ReDoS-safe) regex engine with an re-compatible API

Project description

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.
  • Fast on the common cases. One-pass extraction and a lazy DFA put capture-dense finditer and anchored fullmatch ahead of re, and validation/no-match scans several times faster. It is not the fastest engine at raw throughput (a JIT wins there) — it is the safe one that is also quick.

Not re, on purpose

The unsupported constructs (backreferences, Unicode property classes \p{…}) raise re.error rather than diverge silently, and a few semantics differ deliberately (e.g. a nullable loop's final empty capture). The full list is in COMPATIBILITY.md.

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

real_regex-2026.7.15.tar.gz (219.9 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

real_regex-2026.7.15-cp310-abi3-win_amd64.whl (489.7 kB view details)

Uploaded CPython 3.10+Windows x86-64

real_regex-2026.7.15-cp310-abi3-win32.whl (471.0 kB view details)

Uploaded CPython 3.10+Windows x86

real_regex-2026.7.15-cp310-abi3-musllinux_1_2_x86_64.whl (2.5 MB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ x86-64

real_regex-2026.7.15-cp310-abi3-musllinux_1_2_aarch64.whl (2.5 MB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ ARM64

real_regex-2026.7.15-cp310-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

real_regex-2026.7.15-cp310-abi3-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (1.5 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.24+ ARM64manylinux: glibc 2.28+ ARM64

real_regex-2026.7.15-cp310-abi3-macosx_11_0_arm64.whl (291.7 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

real_regex-2026.7.15-cp310-abi3-macosx_10_9_x86_64.whl (297.9 kB view details)

Uploaded CPython 3.10+macOS 10.9+ x86-64

File details

Details for the file real_regex-2026.7.15.tar.gz.

File metadata

  • Download URL: real_regex-2026.7.15.tar.gz
  • Upload date:
  • Size: 219.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for real_regex-2026.7.15.tar.gz
Algorithm Hash digest
SHA256 d190706a08dab72ae03e4a5751c980324f0e9484462b4386e78e50c80a543bc0
MD5 fa598f56c7992735fa56782bfeefe0cc
BLAKE2b-256 172f5fc6677a23ff4c1503553fc1d20a3275d9237424efce56a54976cb20afb9

See more details on using hashes here.

Provenance

The following attestation bundles were made for real_regex-2026.7.15.tar.gz:

Publisher: release.yml on RECHE23/real-regex

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file real_regex-2026.7.15-cp310-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for real_regex-2026.7.15-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 41d88b3930d470c851a94cf96608c61f086f80f2579fe2540b378775ac737839
MD5 a9807a227b2846385291f7744ed046bc
BLAKE2b-256 5c00f08856e3e5bf871d8e8a4e33d5a9e35098eab504138a0099fe7881527139

See more details on using hashes here.

Provenance

The following attestation bundles were made for real_regex-2026.7.15-cp310-abi3-win_amd64.whl:

Publisher: release.yml on RECHE23/real-regex

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file real_regex-2026.7.15-cp310-abi3-win32.whl.

File metadata

  • Download URL: real_regex-2026.7.15-cp310-abi3-win32.whl
  • Upload date:
  • Size: 471.0 kB
  • Tags: CPython 3.10+, Windows x86
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for real_regex-2026.7.15-cp310-abi3-win32.whl
Algorithm Hash digest
SHA256 52c20aaee3216405b69dd9cafe2ddae1e9f0fd45b4b5cc24c23a0de99a7c8192
MD5 d3907c0b0f6634068f9f5f58a22079f2
BLAKE2b-256 1e4c38d0baaa1bc95cbdca49ae52680d866d6db0305d4630f0f3fcc2f4a7544c

See more details on using hashes here.

Provenance

The following attestation bundles were made for real_regex-2026.7.15-cp310-abi3-win32.whl:

Publisher: release.yml on RECHE23/real-regex

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file real_regex-2026.7.15-cp310-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for real_regex-2026.7.15-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 35b6a2c0f434f9189f485b42247bbe1a007ebadc843b863b13dab2b9d5e182d3
MD5 e151639928ad9d4885b7e85f315030d5
BLAKE2b-256 b9537472076ddbcf6241422e5bc1257eaa5cb971fd02c6fe2771deff9cdcb2b4

See more details on using hashes here.

Provenance

The following attestation bundles were made for real_regex-2026.7.15-cp310-abi3-musllinux_1_2_x86_64.whl:

Publisher: release.yml on RECHE23/real-regex

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file real_regex-2026.7.15-cp310-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for real_regex-2026.7.15-cp310-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 972e981aa80b862e2c96822479f712f211ee4e328ad055912958b04929cbbf19
MD5 64bea25f8168773021516a7819f5e1cb
BLAKE2b-256 e654ab3827abf9ad684d7356cd67ca3dd4837134cece131b3b86c2a38d667f9b

See more details on using hashes here.

Provenance

The following attestation bundles were made for real_regex-2026.7.15-cp310-abi3-musllinux_1_2_aarch64.whl:

Publisher: release.yml on RECHE23/real-regex

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file real_regex-2026.7.15-cp310-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for real_regex-2026.7.15-cp310-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c45ab763fdb43f9b6ee9aeb381d75af1e93ac5fd7dd274e5ed8b5a34c25214d5
MD5 6cbc70b876f61353c72a69f53f804d83
BLAKE2b-256 633755ecc8ba299b87ce2c05a2756579da64dad1f8435cc0be5390a93d7a2927

See more details on using hashes here.

Provenance

The following attestation bundles were made for real_regex-2026.7.15-cp310-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yml on RECHE23/real-regex

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file real_regex-2026.7.15-cp310-abi3-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for real_regex-2026.7.15-cp310-abi3-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 cf6b1489199d934ab7654da52c821da2bab3b8c0b4bec6fe6b656430e7703cfd
MD5 da1dbe08d19b24601999fc3e534483e1
BLAKE2b-256 7dd1bbcc32303a1170d1f8f213338b2d583027102e9a3d3d22b43c59e89e3841

See more details on using hashes here.

Provenance

The following attestation bundles were made for real_regex-2026.7.15-cp310-abi3-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl:

Publisher: release.yml on RECHE23/real-regex

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file real_regex-2026.7.15-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for real_regex-2026.7.15-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 640f49559169ffaae7faf000e676bcd84638d890a0fd31596832e21c2968bff7
MD5 7ee5aeec06a25972657a9b842b8fc26e
BLAKE2b-256 d339182c9bd23fa89c243fc2738d57e5dbbdbe07f8fd383e379cf0abcd94e685

See more details on using hashes here.

Provenance

The following attestation bundles were made for real_regex-2026.7.15-cp310-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on RECHE23/real-regex

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file real_regex-2026.7.15-cp310-abi3-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for real_regex-2026.7.15-cp310-abi3-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 fc3956321f87705f16e41b54fcfce332ce9850d4282bd63b763db446b8cb66a8
MD5 c4596ad37708e6ed467528e38ea48681
BLAKE2b-256 c803e1e8cf60240a6bca64248b4aea2adbe437e715653fe7825fea8127058c3d

See more details on using hashes here.

Provenance

The following attestation bundles were made for real_regex-2026.7.15-cp310-abi3-macosx_10_9_x86_64.whl:

Publisher: release.yml on RECHE23/real-regex

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page