This repository was archived by the owner on Dec 24, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 51
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.
This is an experimental project and it's mean that we do not guarantee stability.