Python bindings to Rust's regress ECMA regular expressions library

2025.10.1 · active · verified Thu Apr 09

regress provides Python bindings to the high-performance Rust `regress` crate, offering ECMA regular expression capabilities. The library is actively maintained, with its current version being 2025.10.1, and follows a frequent release cadence, as seen with multiple releases throughout 2024 and 2025. It aims to provide a fast and reliable regular expression engine compliant with the ECMA-262 specification.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize a `Regex` object, perform a basic search using `find()`, iterate through all matches with `find_iter()`, and utilize flags for pattern matching.

from regress import Regex

# Create a regex object that matches four digits
regex = Regex(r"\\d{4}")

# Test if the pattern is found in a string
match = regex.find("The year is 2024, not 1999.")
print(f"Match found: {match is not None}")

# Find all occurrences
matches = list(regex.find_iter("Years: 1980, 2000, 2020."))
print(f"Number of matches: {len(matches)}")
for m in matches:
    print(f"  Match at start: {m.start()}, end: {m.end()}, text: {m.as_str()}")

# Another example, with flags (e.g., case-insensitive 'i')
# Flags can be passed as a string or a bitmask.
regex_flags = Regex(r"hello", "i")
print(f"Case-insensitive match: {regex_flags.find('Hello World') is not None}")

view raw JSON →