Skip to main content

corvus-regex-ecma262 for Python

Regular expressions with the grammar and the answers of ECMA-262, the RegExp of JavaScript, for Python: the corvus-regex-ecma262 Rust crate, as a typed package with wheels for Linux (glibc and musl), macOS and Windows, x64 and arm64, for every Python from 3.10.

  • Every flag: d, g, i, m, s, u, v and y, with the grammar of each. Without u or v a pattern is read by the Annex B grammar and matched by UTF-16 code unit, as ECMA-262 matches it; with them, by code point. The v flag has nested classes, the difference and the intersection of classes, strings in a class and the properties of strings.
  • ECMAScript 2025: lookbehind, named groups (and a name shared between alternatives), modifier groups such as (?i:...), and every Unicode property ECMA-262 lists, from Unicode 17 tables the crate carries.
  • str and bytes (UTF-8). A pattern answers as it does in a browser or Node, which Python's re does not: \d, \w, \b, . and $, case folding, \p{...} and the rest read as JavaScript reads them.
  • Every match runs without the GIL. A pattern without a backreference is matched in time proportional to its size times the text, and a pattern can be given a match timeout, as a Regex of .NET can, which every method honours and which caps the backtracking memory too, so with a timeout neither a pattern nor a text from outside can make a program hang.

Compliance. Over the ECMA-262 test data (what V8 says about 117,889 patterns and 5,884,566 texts, test262's and exec, the global search, replace and split among them), through this package over str and over bytes, it gives 26,929,347 right answers and none wrong, refuses no valid pattern, accepts no invalid one and reaches no limit. CI runs the whole data on Linux and Windows on every change. (The data asks 21,482 more questions, each a search that starts between the two halves of a character beyond the Basic Multilingual Plane, which a str position cannot name; the crate answers them all over UTF-16.)

Install

pip install corvus-regex-ecma262

Getting started

import corvus_regex_ecma262 as ecma

# The flags are those of new RegExp(pattern, flags).
date = ecma.compile(r"(?<year>\d{4})-(?<month>\d{2})", "gu")

date.test("due 2026-10")                               # True
m = date.search("due 2026-10")
m["year"], m.span(), m.groupdict()                     # '2026', (4, 11), {'year': '2026', 'month': '10'}

# Every match of a global search, as matchAll makes it.
[m.group() for m in date.finditer("2026-10, 2027-01")]  # ['2026-10', '2027-01']

# replace replaces every match with the g flag, and the first without it; a function may give each replacement.
date.replace("2026-10, 2027-01", "$<month>/$1")        # '10/2026, 01/2027'
date.replace("2026-10", lambda m: m["month"])          # '10'

# split splices in what the groups captured; a group that did not take part is None.
ecma.compile(r"\s*(;)\s*").split("a ; b;c")            # ['a', ';', 'b', ';', 'c']

The API

compile(pattern, flags="", *, timeout=None), Regex(...) Compiles a pattern as new RegExp(pattern, flags) does; raises error when it is not valid. timeout is the match timeout in seconds (0 for none; None for default_timeout()).
set_default_timeout(seconds), default_timeout() The timeout of every pattern compiled without one: None (no limit) unless set.
is_valid(pattern, flags="") Whether a pattern is valid, without compiling it.
Regex.test(string, pos=0, *, timeout=None) RegExp.prototype.test with lastIndex at pos (at pos alone with y).
Regex.search(string, pos=0, *, timeout=None) The first match at or after pos, as exec finds it: a Match, or None.
Regex.finditer(string) A global search as matchAll makes it: an iterator of Match.
Regex.replace(string, replacement) String.prototype.replace: the first match, or every match with g; the replacement is a template or a function of the Match.
Regex.replace_all(string, replacement) String.prototype.replaceAll: every match.
Regex.split(string, limit=None) String.prototype.split: a list of strings, None for a group that did not take part.
Regex.pattern, .flags, .timeout, .groups, .group_names What the pattern is.

A Match is read as an re.Match is: group(*groups), m[g], groups(default), groupdict(default), start(g), end(g), span(g) (a group that did not take part is None, at -1), string and re; a group is a number or a name.

Positions. Over a str positions are code points, as Python indexes it; over bytes they are bytes of UTF-8. Without u or v a pattern is matched by UTF-16 code unit, so a match can take half of a character beyond the Basic Multilingual Plane, as in JavaScript: over a str its text holds that half as a lone surrogate, as a JavaScript string would, and its start and end are the whole character's; over bytes the position between the halves is the character's third byte. A str may hold lone surrogates; a lone surrogate written into a pattern is read as U+FFFD (write it as the escape \ud800 to match one).

Errors. error (a ValueError) says why a pattern did not compile in its message and in kind: "pattern", "flags" or "too_large". A match that reaches its timeout, or its cap on backtracking memory, raises MatchLimitError, a kind of error, from whichever method matched; a global search ends there.

Timeouts. A pattern has a match timeout, as a Regex of .NET has: compile(pattern, flags, timeout=1.0), or for every pattern compiled after it set_default_timeout(1.0). Every method that matches gives each of its matches the timeout; test and search take a timeout= of their own in its place. Without a timeout (the default) a match has no limit of time or of memory, so a program that matches a pattern or a text it did not write should set one.

Threads. A Regex is immutable and may be used from any number of threads; matching releases the GIL.

Benchmarks

The Industry workloads of dotnet/performance, this package against Python's re, the regex package and V8, are on the central page, corvus-oss.org/corvus-regex-ecma262-benchmarks, measured nightly on one runner with every other Corvus ECMA-262 engine.

Repository

  • src/lib.rs: the binding (PyO3, abi3); python/corvus_regex_ecma262: the package and its type stubs.
  • tests/: the tests; tools/dataset.py: the test-data runner (python tools/dataset.py <data> wrong.tsv).
  • tools/bench: the benchmark harness and the script the image runs; Dockerfile: the image the central page runs.

Licence

Apache-2.0. See LICENSE.

Metadata

Release files for corvus-regex-ecma262 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 corvus-regex-ecma262 0.2.0
File Size Uploaded Provenance
corvus_regex_ecma262-0.2.0.tar.gz 48.4 kB With provenance Details

Built distributions (wheels)

Table of built distributions (wheels) for corvus-regex-ecma262 0.2.0
File
corvus_regex_ecma262-0.2.0-cp310-abi3-win_arm64.whl CPython 3.10 abi3 Windows ARM64 Details
corvus_regex_ecma262-0.2.0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
corvus_regex_ecma262-0.2.0-cp310-abi3-musllinux_1_2_x86_64.whl CPython 3.10 abi3 Linux musl 1.2+ x86-64 Details
corvus_regex_ecma262-0.2.0-cp310-abi3-musllinux_1_2_aarch64.whl CPython 3.10 abi3 Linux musl 1.2+ ARM64 Details
corvus_regex_ecma262-0.2.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details
corvus_regex_ecma262-0.2.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details
corvus_regex_ecma262-0.2.0-cp310-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl CPython 3.10 abi3 macOS 11.0+ ARM64, macOS 10.12+ x86-64, macOS 10.12+ universal2 (ARM64, x86-64) Details

Total release size: 5.8 MB

Release files / corvus_regex_ecma262-0.2.0.tar.gz

Download URL corvus_regex_ecma262-0.2.0.tar.gz
Size 48.4 kB
Tags Source
SHA-256 checksum
How to use checksums
7cec7f60aca3325f6a8a4e3559c198e852772aa018b1f4e9049e0da937fd86a7
BLAKE2b-256 checksum
How to use checksums
3c9e3bc8370fb67f9b65561c2b826ecd993e91fd3efeeba76e40b393794dabc8
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 Oct 22, 2026.

Transparency log

Release files / corvus_regex_ecma262-0.2.0-cp310-abi3-win_arm64.whl

Download URL corvus_regex_ecma262-0.2.0-cp310-abi3-win_arm64.whl
Size 550.6 kB
Tags CPython 3.10 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
a3dc785ca8b2dc740adb3eb242d90b45090e24bfb5ae7587a08aadf2d14a3d87
BLAKE2b-256 checksum
How to use checksums
64ff585401418771bf3ffb1229057715e95bfd1fe54f245dd044fcd777ba292e
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 Oct 22, 2026.

Transparency log

Release files / corvus_regex_ecma262-0.2.0-cp310-abi3-win_amd64.whl

Download URL corvus_regex_ecma262-0.2.0-cp310-abi3-win_amd64.whl
Size 629.0 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
559a63176b9d80cd110c992ed6579ed65d3b3386af9c79049b9a43eb123f00e8
BLAKE2b-256 checksum
How to use checksums
abbeb83d14a6be33990be2966b110c879e37d625608d1ca45c1852e11b7697b5
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 Oct 22, 2026.

Transparency log

Release files / corvus_regex_ecma262-0.2.0-cp310-abi3-musllinux_1_2_x86_64.whl

Download URL corvus_regex_ecma262-0.2.0-cp310-abi3-musllinux_1_2_x86_64.whl
Size 962.4 kB
Tags CPython 3.10 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
d6f3131502684398980bddaecfb26ff82ef33aa6acae3a7552f6027c3918ff0e
BLAKE2b-256 checksum
How to use checksums
f8f1a98ab93409b98bacf6fe379e35b6f054f239b7d02aee21c65dc1b72173fa
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 Oct 22, 2026.

Transparency log

Release files / corvus_regex_ecma262-0.2.0-cp310-abi3-musllinux_1_2_aarch64.whl

Download URL corvus_regex_ecma262-0.2.0-cp310-abi3-musllinux_1_2_aarch64.whl
Size 864.5 kB
Tags CPython 3.10 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
d2d3217cf6f20783df78b2c6fae35f60611226b418e561817ace5cba3dbe50a4
BLAKE2b-256 checksum
How to use checksums
37007bd3b35a66c504e0187f51d22ac66fdf00ac354b1771450cb171221468e4
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 Oct 22, 2026.

Transparency log

Release files / corvus_regex_ecma262-0.2.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL corvus_regex_ecma262-0.2.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 748.7 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
1e4a629069a89257042bc0e9c1d30eb24bc117878b85667a1db6621ded15d846
BLAKE2b-256 checksum
How to use checksums
fbd33d19c79995efcf3f9ab11fe0df8d7cf8b5f739b047250d035d4266782a99
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 Oct 22, 2026.

Transparency log

Release files / corvus_regex_ecma262-0.2.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL corvus_regex_ecma262-0.2.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 686.4 kB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
69139b4d1f3a1a549a3626d441730abf88acf16c92e9ea7e7130cc152584b9c3
BLAKE2b-256 checksum
How to use checksums
a60eb6f484cb5a6ed221a61c9b97fe70a61318267b544b283ac6b951871a8da2
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 Oct 22, 2026.

Transparency log

Release files / corvus_regex_ecma262-0.2.0-cp310-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl

Download URL corvus_regex_ecma262-0.2.0-cp310-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Size 1.3 MB
Tags CPython 3.10 abi3 macOS 10.12+ universal2 (ARM64, x86-64) macOS 10.12+ x86-64 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
1a5f9660bed99981df8336ab904bf037a186fa30e6ca81d4ac03e7e4f1ecb25d
BLAKE2b-256 checksum
How to use checksums
ed6f0b2bd8a580ef259c8f05c0f7218ff6b88a31cd1fb1e8a129e20235dc298a
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 Oct 22, 2026.

Transparency log

Security for corvus-regex-ecma262 0.2.0

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.

Full provenance

All 8 files in this release have been uploaded with provenance metadata.

Select from 8 files

Attestation for corvus_regex_ecma262-0.2.0.tar.gz

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

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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