Skip to main content

philiprehberger-regex-kit

Tests PyPI version Last updated

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:

⭐ Star the repo

🐛 Report issues

💡 Suggest features

❤️ Sponsor development

🌐 All Open Source Projects

💻 GitHub Profile

🔗 LinkedIn Profile

License

MIT

Release files for philiprehberger-regex-kit 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for philiprehberger-regex-kit 0.2.0
File Size Uploaded
philiprehberger_regex_kit-0.2.0.tar.gz 6.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for philiprehberger-regex-kit 0.2.0
File Interpreter ABI Platform
philiprehberger_regex_kit-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 11.6 kB

Release files / philiprehberger_regex_kit-0.2.0.tar.gz

Download URL philiprehberger_regex_kit-0.2.0.tar.gz
Size 6.5 kB
Tags Source
SHA-256 checksum
How to use checksums
fa196194ede508f54053c6a00fa78a2d7a268a0d92842fba32bb87149c6583fb
BLAKE2b-256 checksum
How to use checksums
37af3709513c1f11ba1c40a52c580351350cba3fac4a5701f111c5fae13116e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release files / philiprehberger_regex_kit-0.2.0-py3-none-any.whl

Download URL philiprehberger_regex_kit-0.2.0-py3-none-any.whl
Size 5.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f9783426f7200306dd3ad5a3d29e4892793d8b2c6648114cc82cd3b1cabbcfc2
BLAKE2b-256 checksum
How to use checksums
a00508182af5f1a2f06e696569cb48fe3dce01b5c342a2b1a93637cbd8131dc3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page