Skip to main content

serp-re

A re drop-in with true backtracking semantics, written in the Serpentine subset. Patterns compile to a small instruction program run by a recursive backtracking VM: alternation is first-alternative-wins, quantifiers are greedy/lazy with full backtracking into repeated bodies, and capture groups record the last iteration — CPython semantics, verified by 30,000+ differential checks against the real re module (including a 3k random pattern fuzz).

API

compile(pattern, flags=0) -> Pattern, match, fullmatch, search (returning Match | None), findall, finditer (eager list[Match]), sub, split, escape, the error exception (CPython 3.11 messages), and flags IGNORECASE/I, MULTILINE/M, DOTALL/S (combine with + — the subset has no | on ints). Match supports group(n)/groups()/start/end/ span/string and prints as <re.Match object; span=(0, 3), match='abc'>.

Supported syntax

Literals, ., escapes (\d \D \w \W \s \S \b \B \A \Z, punctuation, \n \t \r \f \v), classes [abc] / [a-z] / [^...], quantifiers * + ? {m} {m,} {,n} {m,n} plus lazy variants, groups (...), (?:...), (?P<name>...) (positional access), alternation |, anchors ^ $.

Caps (loud errors or documented divergences)

  • No backreferences or lookarounds (raise error).
  • \w/\s classification is ASCII.
  • findall with 2+ capture groups raises (use finditer).
  • groups() returns a PyVal list, not a tuple; split() fills unmatched group parts with '' instead of None.
  • sub replacement is a string template (\1, \g<n>, escapes) — no callables. finditer is eager. {m,n} capped at 1000.
  • The engine recurses while backtracking; very long quantified matches can exhaust the stack.

Install

serp add serp-re
pip install serp-re

Metadata

Release files for serp-re 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for serp-re 0.2.0
File Size Uploaded
serp_re-0.2.0.tar.gz 9.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for serp-re 0.2.0
File Interpreter ABI Platform
serp_re-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 18.7 kB

Release files / serp_re-0.2.0.tar.gz

Download URL serp_re-0.2.0.tar.gz
Size 9.7 kB
Tags Source
SHA-256 checksum
How to use checksums
155259999a7aeb8e8331e0478586f2663b97862d31eafabf3aeca72257e827c5
BLAKE2b-256 checksum
How to use checksums
a645a30e0ceb332c8f5b9e38a3e2249a313849d7983a4e0eb0d6d5939cde9be1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 29, 2026.

Transparency log

Release files / serp_re-0.2.0-py3-none-any.whl

Download URL serp_re-0.2.0-py3-none-any.whl
Size 9.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a7d4a339b6117e0ec6d99d43ec393b9ba2636c81e06e4770f26f512ea6979f14
BLAKE2b-256 checksum
How to use checksums
c4fd82a74cc73dfdccdd1a7ce0e677a76867adfc71530734ed8cf3587ea87957
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 29, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 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