skillfed

repath

Generate regular expressions form ExpressJS path patterns

repath v0.9.0 506.6K downloads/30d#6,285 on PyPI14
Permissive license MIT Abandoned released

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 repath

uv

uv add repath

poetry

poetry add repath

Installing 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

Development Status :: 4 - BetaIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseNatural Language :: EnglishOperating System :: OS IndependentProgramming Language :: Python :: 2Programming Language :: Python :: 3Topic :: InternetTopic :: Internet :: WWW/HTTP

Tags

express path to regexurl path pattern matchingroute parameter extractionpath-to-regexp pythondynamic url routingnamed path parametersexpress-style routes
routingurl-parsingregex-generation

More Internet packages