Pre-built, tested regex patterns for common data formats.
Project description
philiprehberger-regex-kit
Pre-built, tested regex patterns for common data formats.
Installation
pip install philiprehberger-regex-kit
Usage
from philiprehberger_regex_kit import patterns, extract, is_match
# Use compiled patterns directly
if patterns.EMAIL.fullmatch("user@example.com"):
print("Valid email")
# Quick validation by name
is_match("ip_v4", "192.168.1.1") # True
is_match("uuid", "not-a-uuid") # False
Extracting Matches
from philiprehberger_regex_kit import extract
text = "Contact alice@example.com or visit https://example.com"
extract.emails(text) # ["alice@example.com"]
extract.urls(text) # ["https://example.com"]
Available Patterns
from philiprehberger_regex_kit import patterns
patterns.EMAIL # Email addresses
patterns.URL # HTTP/HTTPS URLs
patterns.IP_V4 # IPv4 addresses
patterns.IP_V6 # IPv6 addresses (full form)
patterns.PHONE # Phone numbers
patterns.UUID # UUIDs
patterns.HEX_COLOR # Hex color codes (#fff, #ff00aa)
patterns.DATE_ISO # ISO dates (YYYY-MM-DD)
patterns.TIME_24H # 24-hour time (HH:MM or HH:MM:SS)
patterns.CREDIT_CARD # Credit card numbers
patterns.MAC_ADDRESS # MAC addresses
patterns.DOMAIN # Domain names
API
patterns
| Attribute | Description |
|---|---|
patterns.EMAIL |
Compiled pattern for email addresses |
patterns.URL |
Compiled pattern for HTTP/HTTPS URLs |
patterns.IP_V4 |
Compiled pattern for IPv4 addresses |
patterns.IP_V6 |
Compiled pattern for IPv6 addresses |
patterns.PHONE |
Compiled pattern for phone numbers |
patterns.UUID |
Compiled pattern for UUIDs |
patterns.HEX_COLOR |
Compiled pattern for hex color codes |
patterns.DATE_ISO |
Compiled pattern for ISO 8601 dates |
patterns.TIME_24H |
Compiled pattern for 24-hour time |
patterns.CREDIT_CARD |
Compiled pattern for credit card numbers |
patterns.MAC_ADDRESS |
Compiled pattern for MAC addresses |
patterns.DOMAIN |
Compiled pattern for domain names |
extract
| Method | Description |
|---|---|
extract.emails(text) |
Extract all email addresses |
extract.urls(text) |
Extract all URLs |
extract.phones(text) |
Extract all phone numbers |
extract.ips(text) |
Extract all IPv4 addresses |
extract.uuids(text) |
Extract all UUIDs |
is_match(pattern_name, value)
| Parameter | Description |
|---|---|
pattern_name |
Pattern name string (e.g. "email", "ip_v4", "uuid") |
value |
The string to validate |
| Returns | bool — True if the entire value matches |
Development
pip install -e .
python -m pytest tests/ -v
Support
If you find this project useful:
License
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file philiprehberger_regex_kit-0.2.0.tar.gz.
File metadata
- Download URL: philiprehberger_regex_kit-0.2.0.tar.gz
- Upload date:
- Size: 6.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fa196194ede508f54053c6a00fa78a2d7a268a0d92842fba32bb87149c6583fb
|
|
| MD5 |
ec7738676338db1fec6b63ed4f74cee5
|
|
| BLAKE2b-256 |
37af3709513c1f11ba1c40a52c580351350cba3fac4a5701f111c5fae13116e9
|
File details
Details for the file philiprehberger_regex_kit-0.2.0-py3-none-any.whl.
File metadata
- Download URL: philiprehberger_regex_kit-0.2.0-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f9783426f7200306dd3ad5a3d29e4892793d8b2c6648114cc82cd3b1cabbcfc2
|
|
| MD5 |
c8749723921390ec627a39d72e3f3532
|
|
| BLAKE2b-256 |
a00508182af5f1a2f06e696569cb48fe3dce01b5c342a2b1a93637cbd8131dc3
|