Skip to content

lucianocordeiro01/mre

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

97 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Maker Regular Expression

PyPI

This is a simple package to make regular expressions in Python.

pip install mre

Documentation:

Examples

from mre import Regex, Group

rgx_one = Regex("Hello world")  # Hello world
rgx_two = Regex("Hello", " world")  # Hello world
rgx_three = Regex("Hello") + " " + Regex("world")  # Hello world
rgx_four = Regex('<', Group('h[1-6]'), '>')  # <(h[1-6])>
rgx_five = Regex('<', Regex.SLASH, 1, '>')  # <\/\1>
from mre import Set
from mre.helper import Range

# All digits
digits = Set(Range(0, 9))
# Add comment
digits = digits.comment('Get all digits')

# Output: [0-9](?#Get all digits)
from mre import Regex, Set, Comment

# All digits
digits = Set(Regex("0-9"))
# CEP comment
cep_comment = Comment('Get zip code Brazil on input')
# CEP regex
rgx_cep = Regex(
    digits.quantifier(5),
    Regex("-").quantifier(0, 1),
    digits.quantifier(3),
    cep_comment
)

# Output: [0-9]{5}-?[0-9]{3}(?#Get zip code Brazil on input)

Contributing documentation

pip install -r requirements-dev.txt

Running documentation

mkdocs serve

Change or create files in the docs folder.

About

Maker Regular Expressions

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%