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 — geometric mean 2.06× across a broad corpus (CI [1.37, 3.12]). One-pass extraction and a lazy DFA make sparse findall 9.6×, multiline anchors 30×, and capture-dense group extraction (emails: 1.07×, up from a 0.32× loss before the one-pass work) beat re; 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: 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.

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.48.tar.gz (462.6 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.48-cp310-abi3-win_amd64.whl (840.3 kB view details)

Uploaded CPython 3.10+Windows x86-64

real_regex-2026.7.48-cp310-abi3-win32.whl (809.0 kB view details)

Uploaded CPython 3.10+Windows x86

real_regex-2026.7.48-cp310-abi3-musllinux_1_2_x86_64.whl (3.7 MB view details)

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

real_regex-2026.7.48-cp310-abi3-musllinux_1_2_aarch64.whl (3.6 MB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ ARM64

real_regex-2026.7.48-cp310-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (2.6 MB view details)

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

real_regex-2026.7.48-cp310-abi3-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (2.6 MB view details)

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

real_regex-2026.7.48-cp310-abi3-macosx_11_0_arm64.whl (649.9 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

real_regex-2026.7.48-cp310-abi3-macosx_10_9_x86_64.whl (662.3 kB view details)

Uploaded CPython 3.10+macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: real_regex-2026.7.48.tar.gz
  • Upload date:
  • Size: 462.6 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.48.tar.gz
Algorithm Hash digest
SHA256 7fc273a2b6ce2f6e60d1bfe8e5deb72d364f09572f7caa8d2818aaca8ffe9452
MD5 239297f6c2bebc0dc6db1720fcbdb1f6
BLAKE2b-256 6763a36aec024afbb0ebbb8d106d252911142e46b1bcfd36dd4c77390ced7a0a

See more details on using hashes here.

Provenance

The following attestation bundles were made for real_regex-2026.7.48.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.48-cp310-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for real_regex-2026.7.48-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 03274c56773d6d9aff13de9384e10187eba4a26bcd81181c03d35f0e728db739
MD5 cfc482d05c4dd2e44ef97441f49347cb
BLAKE2b-256 d4b935e92360819c01a5fbe9d42e5ccd19cbe3e005d9166c915db909fb742bcf

See more details on using hashes here.

Provenance

The following attestation bundles were made for real_regex-2026.7.48-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.48-cp310-abi3-win32.whl.

File metadata

  • Download URL: real_regex-2026.7.48-cp310-abi3-win32.whl
  • Upload date:
  • Size: 809.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.48-cp310-abi3-win32.whl
Algorithm Hash digest
SHA256 742a79bae5bf3510aa3722f891e4976fdd3cec61196b747bc32cb292e58de88e
MD5 9afbf1f8bc348bb1a44c1e1670e2b551
BLAKE2b-256 155b9829fa03af77fb52323f33b7573ba75c51330a7e3f1c14436252c23ff245

See more details on using hashes here.

Provenance

The following attestation bundles were made for real_regex-2026.7.48-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.48-cp310-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for real_regex-2026.7.48-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 fb502a658111f8f08c724d98bffe96c521404a5609142677dfbef18d8859efd8
MD5 69cbe37307166b7f270d502a695db26b
BLAKE2b-256 1801ecc14d43f7d9a154bf92174e115069170678c9287813defa5f39b3ee7550

See more details on using hashes here.

Provenance

The following attestation bundles were made for real_regex-2026.7.48-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.48-cp310-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for real_regex-2026.7.48-cp310-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 90698587920d04513815bb91569a55dbfea5c001deed9010a3d3b28ab459c7f1
MD5 f36af1c2b1898fb4ccd7a0f349bacb71
BLAKE2b-256 726fd7c32b052f786039f82fcf857ecb1a97184abf1c7faef88645cb8fa79a47

See more details on using hashes here.

Provenance

The following attestation bundles were made for real_regex-2026.7.48-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.48-cp310-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for real_regex-2026.7.48-cp310-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a8c1d8dcd30eece201d2475e13e093d04a7226d412de22b9b46e6fcd3c49b45b
MD5 b8313143cc2b7f98464dde0e8d650a58
BLAKE2b-256 8fff27d6cc0932b280fab682b41fd6c917b62aa1bfa95ce730f93aca6f653710

See more details on using hashes here.

Provenance

The following attestation bundles were made for real_regex-2026.7.48-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.48-cp310-abi3-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for real_regex-2026.7.48-cp310-abi3-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 7839bdb493bb8c9ad03d275fdc56e8edcb14529809f199f2bf5d5f528b73a252
MD5 9bd6901793ac0eac08251a4b0dcbcce1
BLAKE2b-256 300d687dda1ba7d05bfb31db095e21cf2a95593971897610a72d8aadf6b2b95e

See more details on using hashes here.

Provenance

The following attestation bundles were made for real_regex-2026.7.48-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.48-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for real_regex-2026.7.48-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a76298085d95e9336b63e106ee47814e11cb2b890809fab28f651f5a448b055c
MD5 20b1957bf0ab579b4a8c260a0bb4c0a4
BLAKE2b-256 8f8a56de9f547fc079d5445e4e9d60e52a669c5a2028866a1beb8355c0485398

See more details on using hashes here.

Provenance

The following attestation bundles were made for real_regex-2026.7.48-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.48-cp310-abi3-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for real_regex-2026.7.48-cp310-abi3-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 86e623b56c6a500db0153c6fd59abc29bbe4dab38e04b2b48858cf25e036b59f
MD5 cd620fe02926e2a91eeee72af53daa08
BLAKE2b-256 8d7def039541ac0bff30904be56426f33fca2c750e57817f042a9a2b9d32c94d

See more details on using hashes here.

Provenance

The following attestation bundles were made for real_regex-2026.7.48-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.

Release history Release notifications | RSS feed

2026.8.17

9 files

2026.8.16

9 files

2026.8.15

9 files

2026.8.14

9 files

2026.8.13

9 files

2026.8.12

9 files

2026.8.11

9 files

2026.8.10

9 files

2026.8.9

9 files

2026.8.8

9 files

2026.8.7

9 files

2026.8.6

9 files

2026.8.5

9 files

2026.8.4

9 files

2026.8.3

9 files

2026.8.2

9 files

2026.8.1

9 files

2026.8.0

9 files

2026.7.63

9 files

2026.7.62

9 files

2026.7.61

9 files

2026.7.60

9 files

2026.7.59

9 files

2026.7.58

9 files

2026.7.57

9 files

2026.7.56

9 files

2026.7.55

9 files

2026.7.54

9 files

2026.7.53

9 files

2026.7.52

9 files

2026.7.51

9 files

2026.7.50

9 files

2026.7.49

9 files

This release

2026.7.48 This release

9 files

2026.7.47

9 files

2026.7.46

9 files

2026.7.45

9 files

2026.7.44

9 files

2026.7.43

9 files

2026.7.42

9 files

2026.7.41

9 files

2026.7.40

9 files

2026.7.39

9 files

2026.7.38

9 files

2026.7.37

9 files

2026.7.36

9 files

2026.7.35

9 files

2026.7.34

9 files

2026.7.33

9 files

2026.7.32

9 files

2026.7.31

9 files

2026.7.30

9 files

2026.7.29

9 files

2026.7.28

9 files

2026.7.27

9 files

2026.7.26

9 files

2026.7.25

9 files

2026.7.24

9 files

2026.7.23

9 files

2026.7.22

9 files

2026.7.21

9 files

2026.7.20

9 files

2026.7.19

9 files

2026.7.18

9 files

2026.7.17

9 files

2026.7.16

9 files

2026.7.15

9 files

2026.7.14

9 files

2026.7.13

9 files

2026.7.12

9 files

2026.7.11

9 files

2026.7.10

9 files

2026.7.9

9 files

2026.7.8

9 files

2026.7.7

9 files

2026.7.6

9 files

2026.7.5

9 files

2026.7.4

9 files

2026.7.3

9 files

2026.7.2

9 files

2026.7.1

9 files

2026.7.0

9 files

2026.6.21

9 files

2026.6.20

9 files

2026.6.19

9 files

2026.6.18

9 files

2026.6.17

9 files

2026.6.16

9 files

2026.6.15

9 files

2026.6.14

9 files

2026.6.13

9 files

2026.6.12

9 files

2026.6.11

9 files

2026.6.10

9 files

2026.6.9

9 files

2026.6.8

9 files

2026.6.7

9 files

2026.6.6

9 files

2026.6.5

9 files

2026.6.4

9 files

2026.6.3

9 files

2026.6.2

9 files

2026.6.1

9 files

2026.6.0

9 files

Supported by

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