backrefs
A wrapper around re and regex that adds additional back references.
What it is and what it does
Backrefs is a wrapper around Python's built-in re module and the third-party regex library that adds backreference syntax and features not available in either engine natively. It enables patterns like Unicode property escapes (\p{Letter}) and case-conversion backreferences (\C, \E) that are common in other regex engines but absent from Python's standard tools.
The package is designed for developers who need advanced regex capabilities within Python without rewriting patterns or switching languages. It sits as a compatibility layer, translating extended syntax into operations the underlying engine can execute. With no runtime dependencies and support for current Python versions, it integrates as a drop-in replacement for re or regex in projects requiring these additional features.
Use it for:
- Converting matched text to uppercase or other cases using backreferences in substitutions.
- Writing regex patterns with Unicode property classes like \p{Letter} or \p{Digit}.
- Porting regex patterns from other languages that support extended backreferences into Python.
- Processing multilingual text where Unicode character properties simplify pattern matching.
- Building text transformation pipelines that rely on advanced regex features.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Backrefs extends Python's re and regex libraries with additional backreference features and syntax not natively supported, such as Unicode property escapes and case-conversion backreferences.
Yes, if you need extended regex features like Unicode properties or case-conversion backreferences. The package is actively maintained, has no dependencies, installs easily, carries a permissive MIT license, and ranks in the top 5000 PyPI packages. Install only if your patterns genuinely require features beyond standard re or regex; otherwise, the added layer is unnecessary.
Install
backrefs on PyPI
pip
pip install backrefsuv
uv add backrefspoetry
poetry add backrefsInstalling backrefs
Before you install
Low friction installation with wheels available for Python 3.10 through 3.14. Package is actively maintained with a recent release (19 days ago) and no runtime dependencies.
License in practice
MIT license permits unrestricted use, modification, and distribution in commercial and private projects with minimal attribution requirements.
Quickstart
from backrefs import bre
pattern = bre.compile(r'(\p{Letter}+)')
result = pattern.sub(r'\C\1\E', 'sometext')
Requires Python 3.10 or later.
Verify before relying
- Whether the package wraps both re and regex engines or primarily one of them in typical usage.
- Performance overhead compared to direct re or regex library calls.
- Scope and completeness of backreference features supported across different regex engines.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 19 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 13,528,784/month — #1,276 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: backrefs-8.0-py310-none-any.whl; backrefs-8.0-py311-none-any.whl; backrefs-8.0-py312-none-any.whl; backrefs-8.0-py313-none-any.whl; backrefs-8.0-py314-none-any.whl
Keywords: re, regex
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
google-re2A drop-in replacement for Python's re module…
permissive · top 5,000 on PyPI
regexA drop-in replacement for Python's standard…
permissive · top 100 on PyPI
regexploitRegexploit analyzes regular expressions to…
permissive · top 15,000 on PyPI
bracexBracex expands Bash-style brace patterns into…
permissive · top 1,000 on PyPI
real-regexA drop-in replacement for Python's `re` module…
permissive · top 15,000 on PyPI
pymdown-extensionsPymdown Extensions provides a collection of…
permissive · top 1,000 on PyPI
flpcflpc wraps the Rust regex crate to provide…
permissive · top 5,000 on PyPI
rebulkReBulk provides a fluent API for building…
permissive · top 15,000 on PyPI
iregexp-checkValidates regular expressions against RFC 9485…
permissive · top 15,000 on PyPI
weakrefmethodProvides a WeakMethod class for storing bound…
permissive · top 15,000 on PyPI