repath
Generate regular expressions form ExpressJS path patterns
What it is and what it does
repath is a Python port of the Node.js path-to-regexp module. It takes Express-style path strings—where parameters are marked with colons like `:name`—and generates regular expression patterns you can compile and use with Python's re module to match and extract values from URL paths. The package handles named parameters, optional segments (suffixed with `?`), zero-or-more matches (`*`), one-or-more matches (`+`), custom regex patterns, and unnamed capture groups.
You use it by calling repath.pattern() to generate a regex pattern string, then compiling that pattern with re.compile() and matching against actual URL paths. It also provides a template() function to reverse the process—taking a path template and a dictionary of values to generate a filled-in path string. The package exposes lower-level functions like parse() and tokens_to_pattern() for advanced use cases.
Use it for:
- Build a web framework or routing layer that needs to match incoming URL paths to handler functions using Express-like syntax.
- Parse and validate dynamic URL structures where path segments contain variable data that must be extracted.
- Generate URL patterns for testing or documentation that describe what paths your application will accept.
- Convert Express route definitions to Python patterns when porting Node.js applications.
- Create a URL templating system where you define a pattern once and generate concrete URLs with different parameter values.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Converts Express-style path strings (like `/user/:name`) into regular expression patterns that can match and extract URL path parameters.
Yes, but with caution. The package is stable and has no known vulnerabilities, and it solves a specific problem well if you need Express-style path-to-regex conversion in Python. However, it is abandoned—no updates since 2019—so if you encounter bugs or need features, you will need to fork or patch it yourself. For new projects, verify that the dependency on six and the lack of recent Python version testing do not create compatibility issues in your environment.
Install
repath on PyPI
pip
pip install repathuv
uv add repathpoetry
poetry add repathInstalling repath
Before you install
Installation is straightforward with low friction—a pure Python wheel with only six as a runtime dependency. However, the package is abandoned; the last release was in 2019 and no commits have been made since then.
License in practice
MIT license permits free use, modification, and distribution with minimal restrictions, making it safe to adopt in most projects.
Quickstart
import re
import repath
pattern = repath.pattern('/user/:name')
match = re.match(pattern, '/user/alice')
if match:
params = match.groupdict()
Verify before relying
- Whether the package works correctly with modern Python versions beyond those tested at release time.
- Whether six dependency is still necessary or if Python 2 support is still relevant for current use.
Package facts
| License | MIT (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — six |
| Maintenance | abandoned — 2,502 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 506,625/month — #6,285 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: repath-0.9.0-py3-none-any.whl
Keywords: url, path, pattern, regex, express, route
Tags
More Internet packages
Botocore provides low-level, data-driven access…
permissive · top 100 on PyPI
aiobotocoreProvides an async client for AWS services using…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
filelockProvides a platform-independent file locking…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
googleapis-common-protosProvides common Protocol Buffer message…
permissive · top 100 on PyPI
exrexExrex generates all or random strings matching…
agpl · top 15,000 on PyPI
sanic-routingSanic-routing is a low-level AST-style router…
permissive · top 5,000 on PyPI
greeneryParses and manipulates regular expressions by…
permissive · top 15,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
stringparserExtracts values from strings using…
permissive · top 15,000 on PyPI
re-assertProvides a helper class for regex assertions…
permissive · top 15,000 on PyPI
iregexp-checkValidates regular expressions against RFC 9485…
permissive · top 15,000 on PyPI
regressProvides Python bindings to the Rust regress…
permissive · top 5,000 on PyPI
multiregexMatches multiple regex patterns against a…
permissive · top 15,000 on PyPI