skillfed

backrefs

A wrapper around re and regex that adds additional back references.

backrefs v8.0 13.5M downloads/30d#1,276 on PyPI13
Permissive license MIT Active released

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 backrefs

uv

uv add backrefs

poetry

poetry add backrefs

Installing 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

Development Status :: 5 - Production/StableEnvironment :: ConsoleIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Topic :: Software Development :: Libraries :: Python ModulesTyping :: Typed

Tags

regex backreferencesextended regex featuresunicode property escapescase conversion regexpython regex wrapperadvanced regex patternsregex enhancements
regex-wrapperunicode-patternstext-processing

More Python Modules packages