Skip to content
This repository has been archived by the owner on Dec 24, 2021. It is now read-only.

How to use compiled patterns.

Líkið Geimfari edited this page Aug 24, 2017 · 3 revisions

Examples that illustrate a basic of expynent.

>>> import expynent
>>> from expynent.compiled import *

>>>  credit_cards = (
    '3519 2073 7960 3241',
    '3519-2073-7960-3241',
    '3519207379603241'
)

>>> for card in credit_cards:
        if CREDIT_CARD.match(card):
            print('Valid')
        else:
            print('Invalid')

# Output: 
Valid
Valid
Valid

>>> import expynent
>>> from expynent.compiled import *

slug = 'some-great-slug'

if SLUG.match(slug):
    print('Valid')
else:
    print('Invalid')

# Output: 
Valid

So, just import pattern that you want to use ant use math() method.

Clone this wiki locally