Expynent is a tiny library that provides common regular expression patterns. This can be useful if you don't want to write regular expression manually. Also you can use this library as fixture for testing framework like a py.test.
~ pip install expynent
Just import the pattern that you want:
import re
from expynent.patterns import ZIP_CODE
if re.match(ZIP_CODE['RU'], '43134'):
print('match')
else:
print('not match')
# Output: 'not match'
also you can use compiled patterns:
from expynent.compiled import URL
url = 'http://foo.com/blah_blah_(wikipedia)_(again)'
if URL.match(url):
print('valid')
else:
print('invalid')
# Output: 'valid'
You can look at the list of supported patterns below:
BITCOIN_ADDRESS
CREDIT_CARD
CREDIT_CARD_STRICT
EMAIL_ADDRESS
ETHEREUM_ADDRESS
FLOAT_NUMBER
HEX_VALUE
IP_V4
IP_V6
IRC
ISBN
ISO_8601_DATETIME
LATITUDE
LICENSE_PLATE
LONGITUDE
MAC_ADDRESS
PGP_FINGERPRINT
PHONE_NUMBER
ROMAN_NUMERALS
SLUG
TIME_24H_FORMAT
URL
UUID
YANDEX_MONEY
ZIP_CODE
ETHEREUM_HASH
Your contributions are always welcome! Please take a look at the contribution guidelines first.
This is an experimental project and it's mean that we do not guarantee stability. We try to write tests for all expressions, but we cannot guarantee the perfect operation of regular expressions because it is impossible to cover all cases.