Readable regular expressions in Python
Project description
🦄 Magic RegEx
Readable Regular Expressions for Python
- Runtime is ultra-minimal
- Compiles to pure RegEx
- Automatically typed capture groups
- Natural language syntax
This library is a port of the magic-regexp JavaScript module by Daniel Roe.
Quickstart
First, install magicregex
by
pip install magicregex
Second, find e-mails in text by
import magicregex as mre
reg = mre.createRegEx(
mre.exactly(
mre.letter.TimesAtLeast(1)
.And(mre.exactly('@'))
.And(mre.letter.TimesAtLeast(1))
.And(mre.exactly('.'))
.And(mre.letter.TimesAtLeast(2))
)
)
reg.findall('daniel@roe.uk lore ipsum thomas@wollmann.de')
# Result: ['daniel@roe.uk', 'thomas@wollmann.de']
Documentation
Up to now, this module is compatible with magic-regexp's documentation.
Contribute
Made with ❤️. If you want to support:
- Clone this repository
- Install dependencies using
poetry install --with dev
- Run tests using
pytest
- Run code checks using
pre-commit run
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
magicregex-0.1.1.tar.gz
(8.3 kB
view hashes)
Built Distribution
Close
Hashes for magicregex-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aa81603200a10b63ef897489dff829e9685973a6efc70eeae0763cc5ec6f2770 |
|
MD5 | 7d3f1b99eeba4a4d1e977231fc9d9fb0 |
|
BLAKE2b-256 | c6783b55869af1665cd264cafc3402f24425302d7f885780053c5a8499a746aa |