Skip to content

Expressive Regex

PyPI - License PyPI - License Codecov

This project was made with inspiration from Super Expressive for JavaScript.

Expressive Regex allow you to build regular expressions in almost natural language and without external dependency.

Documentation

Example to match a telephone number that can be in the format 555-555-555, 555 555 555 or 555555555.

ExpressiveRegex()\
    .exactly(2).group\
        .oneOrMore.digit\
        .optional.setOfLiterals\
            .char('-')\
            .whitespaceChar\
        .end()\
    .end()\
    .oneOrMore.digit\
.toRegexString()
"(?:\d+[\-\s]?){2}\d+"