Skip to main content

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.1

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.1
File Size Uploaded Provenance
remagic-0.2.1.tar.gz 14.4 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 31.2 kB

Release files / remagic-0.2.1.tar.gz

Download URL remagic-0.2.1.tar.gz
Size 14.4 kB
Tags Source
SHA-256 checksum
How to use checksums
0511c9e2a5e40e39fbc384dcce59fc1b0c36e8c43dd49fdce051c1da592acf95
BLAKE2b-256 checksum
How to use checksums
6ff07081f30e985cd5c7facd5a9b26407bdf9a9bf2d4603aab66414cff25cebf
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.1-py3-none-any.whl

Download URL remagic-0.2.1-py3-none-any.whl
Size 16.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2bcece5558362ffee9877256869fcc5fd4b0b3de8bee87f57d50d364dc90af86
BLAKE2b-256 checksum
How to use checksums
0c07ca6cadaf45d5612b6d36f81b03926fe9333fe66ab06e4841cccc93fc8ee2
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.1

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