Skip to content

Latest commit

 

History

History
51 lines (39 loc) · 1.38 KB

README.md

File metadata and controls

51 lines (39 loc) · 1.38 KB

🦄 Magic RegEx

Readable Regular Expressions for Python

Stable Version Python Versions License Downloads

  1. Runtime is ultra-minimal
  2. Compiles to pure RegEx
  3. Automatically typed capture groups
  4. 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('[email protected] lore ipsum [email protected]') 
# Result: ['[email protected]', '[email protected]']

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