regex-rs documentation

regex-rs

Supported Python versions PyPI - Version Documentation status Ruff

Python bindings to the Rust regex crate.

Installation

From PyPI:

pip install regexrs-py

Usage

>>> from regex_rs import Regex
>>> r = Regex(r"(?<year>\d{4})-(?<month>\d{2})")
>>> r.is_match("released in 2026-10")
True
>>> r.find("released in 2026-10")
<regex_rs.Match span=(12, 19) text='2026-10'>
>>> r.captures("released in 2026-10")["year"].text
'2026'
>>> r.replace_all("2026-10, 2027-01", "$month/$year")
'10/2026, 01/2027'

The current version of the regex crate used is 1.13.1.