Skip to main content

unmatcher

unmatcher tries to solve the following problem:

Given a regular expression, find any string that matches the expression.

Why? Mostly just because. But one possible application is to generate test data for string processing functions.

Status

PyPI package version License Build Status

Most typical elements of regexes are supported:

  • multipliers: *, +

  • capture groups: |, ( ) (including backreferences)

  • character classes (\d|\w|\s etc.) and character sets ([])

API

unmatcher module exposes a single reverse function. It takes a regular expression - either in text or compiled form - and returns a random string that matches it:

>>> import unmatcher
>>> print unmatcher.reverse(r'\d')
7

Additional arguments can be provided, specifying predefined values for capture groups inside the expression. Use positional arguments for numbered groups ('\1', etc.):

>>> import unmatcher
>>> print unmatcher.reverse(r'<(\w+)>.*</\1>', 'h1')
<h1>1NLNVlrOT4YGyHV3vD7cHvrAl8OHVWDPKgmaE4gUsctboyFYUx</h1>

and keyword arguments for named groups:

>>> import unmatcher
>>> print unmatcher.reverse('(?P<foo>\w+)__(?P=foo)', foo='bar')
bar__bar

Note that a predefined value is not validated against actual subexpression for the capture group.

Metadata

Release files for unmatcher 0.1.4

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

Source distribution (sdist)

Source distribution for unmatcher 0.1.4
File Size Uploaded Provenance Actions
unmatcher-0.1.4.tar.gz 7.4 kB Without provenance Details for unmatcher-0.1.4.tar.gz

Release files / unmatcher-0.1.4.tar.gz

Download URL unmatcher-0.1.4.tar.gz
Size 7.4 kB
Tags Source
SHA-256 checksum
How to use checksums
d53129eae915230c0db238315b76251cdc9df8ad12a28ca149028de3259f31b3
BLAKE2b-256 checksum
How to use checksums
ac9eb999f4ff11f7e3fb55fa3182ab96804d2c74f661b8a9f624d3f7f44783b6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for unmatcher 0.1.4

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