Skip to main content

regexorcist

Regular expressions, but with an exorcist. The power of Python compels you!

Find, banish and cleanse text patterns with a friendlier API on top of Python's re. Your patterns are still regular expressions. They just have a priest now.

Install

pip install regexorcist

Usage

import regexorcist

text = "Call 555-1234 or 555-9876 for a free demon inspection."

demons = regexorcist.find(r"\d{3}-\d{4}", text)

demons.count()            # 2
demons.texts()            # ['555-1234', '555-9876']
demons.exorcise()         # 'Call  or  for a free demon inspection.'
demons.baptize("[PHONE]") # 'Call [PHONE] or [PHONE] for a free demon inspection.'
print(demons.confess())
# Found 2 demons:
#   1. '555-1234' at 5-13
#   2. '555-9876' at 17-25

One-liners:

regexorcist.is_possessed(r"demon", text)        # True
regexorcist.exorcise(r"\d{3}-\d{4}", text)
regexorcist.baptize(r"\d{3}-\d{4}", text, "#")

Holy water (ready-made patterns)

from regexorcist import holy_water

regexorcist.find(holy_water.EMAIL, "write to a@b.com").texts()

Available: EMAIL, URL, IPV4, HEX_COLOR, HASHTAG, PHONE.

Errors with personality

regexorcist.find(r"(abc", "text")
# RegexorcistError: Unclosed parenthesis. Your pattern is possessed. (position 0)

RegexorcistError is a ValueError, so existing error handling keeps working.

API

regexorcist standard re equivalent
find() re.finditer()
Demons.exorcise() re.sub(pattern, "", text)
Demons.baptize(x) re.sub(pattern, x, text)
is_possessed() re.search() is not None

Development

pip install -e . pytest
pytest

License

MIT

Metadata

Release files for regexorcist 0.1.0

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

Source distribution (sdist)

Source distribution for regexorcist 0.1.0
File Size Uploaded Provenance Actions
regexorcist-0.1.0.tar.gz 6.8 kB Without provenance Details for regexorcist-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 12.2 kB

Release files / regexorcist-0.1.0.tar.gz

Download URL regexorcist-0.1.0.tar.gz
Size 6.8 kB
Tags Source
SHA-256 checksum
How to use checksums
d230211eb97584bdb84c6c9e24ad2cd485e81cd01dfb4ac8d1743bba66bd44c0
BLAKE2b-256 checksum
How to use checksums
5241a8e8c33a2d5ad56603c81918fd06402a3ae5e8746722d9450505e663108e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.5

Release files / regexorcist-0.1.0-py3-none-any.whl

Download URL regexorcist-0.1.0-py3-none-any.whl
Size 5.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9deb6ee57eeb4020e10b6c1fb2f5a9ff5188acd07cc85ac96a2985987da5c352
BLAKE2b-256 checksum
How to use checksums
fc428b867ac56ddbd5e843a9790129b37fe5be7e87ed651d001b2eed1e9144b5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.5

Security for regexorcist 0.1.0

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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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