Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

build PyPI - Python Version PyPI - License

remagic logo

remagic

Build regular expressions from composable, typed Python objects. Partly inspired by magic-regexp for Node.

>>> import remagic as rm
>>> year = rm.DIGIT.times(4).group("year")
>>> month = rm.DIGIT.times(2).group("month")
>>> date = rm.START + year + "-" + month + rm.END
>>> date.compile().fullmatch("2027-01")["year"]
'2027'

Patterns are immutable. Strings are matched literally, + concatenates, | alternates, and (?:...) is added only where precedence needs it:

>>> str((rm.exactly("a") | "b").times(2))
'(?:a|b){2}'

Installation

uv add remagic            # or: pip install remagic
uv add "remagic[regex]"   # optional: the `regex` engine

Requires Python 3.11+. Patterns compile with the standard re module. Features that only regex supports, such as unicode_property("L"), switch to it automatically and need the regex extra.

Learn more

See the quickstart, concepts and cookbook in the docs, or the building blocks below.

Building blocks

  • Constants: DIGIT, WORD, WHITESPACE, LETTER, CHAR, NEWLINE, ... and anchors START, END, WORD_BOUNDARY, ...
  • Characters: exactly, char_in, char_not_in, char_range, any_of, unicode_property
  • Quantifiers: optional, zero_or_more, one_or_more, times, between, at_least, each with lazy= and possessive=
  • Groups: group (numbered or named), non_capturing, atomic, ref
  • Assertions: before, not_before, after, not_after, and the methods followed_by, not_followed_by, preceded_by, not_preceded_by
  • Flags: scoped, ignore_case, multiline, dotall
  • Every function has a matching Pattern method.

Development

uv sync
uv run pytest        # 100% line and branch coverage is required
uv run ruff check . && uv run ruff format --check . && uv run mypy
uv run --group docs sphinx-build -W -b html docs docs/_build   # build the docs

Metadata

Release files for remagic 0.2.0b1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for remagic 0.2.0b1
File Size Uploaded Provenance
remagic-0.2.0b1.tar.gz 14.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for remagic 0.2.0b1
File Interpreter ABI Platform
remagic-0.2.0b1-py3-none-any.whl Python 3 none any Details

Total release size: 31.1 kB

Release files / remagic-0.2.0b1.tar.gz

Download URL remagic-0.2.0b1.tar.gz
Size 14.3 kB
Tags Source
SHA-256 checksum
How to use checksums
e9ba52dfa9da513701319d150ddb9ba6cc7e4bc7bbf3d4de066ffe9f0297dd7c
BLAKE2b-256 checksum
How to use checksums
d9226d858fd1338737d77a289bedeeda15a12d99b030288fb2d5a39936a539cf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / remagic-0.2.0b1-py3-none-any.whl

Download URL remagic-0.2.0b1-py3-none-any.whl
Size 16.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3d2715f8daf47f81c5c4e2cceb4a1d8445a0bd5acddb528462d7a2aeea8c9230
BLAKE2b-256 checksum
How to use checksums
5aed3c728f6be080a5a3b868101a01d4e13cf7f9b3fda8626b257b278586c8b2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for remagic 0.2.0b1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page