Skip to main content

Pre-built, tested regex patterns for common data formats.

Project description

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

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

philiprehberger_regex_kit-0.1.2.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

philiprehberger_regex_kit-0.1.2-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file philiprehberger_regex_kit-0.1.2.tar.gz.

File metadata

File hashes

Hashes for philiprehberger_regex_kit-0.1.2.tar.gz
Algorithm Hash digest
SHA256 5572ea483982e35d8961946cf5a5c1462d24d1a03fef459c1d127a3ed7658320
MD5 bc33f1330bfe5b55ffc79ec66310cdde
BLAKE2b-256 43e0596bc07ae26e5eaa26c7c3962ae93869463a4c280657bf278065246e733c

See more details on using hashes here.

File details

Details for the file philiprehberger_regex_kit-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for philiprehberger_regex_kit-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2e2bb7694eddd6ce0ef8043a511267ce076f3ea31d0b6f08cd1e43bf20ea70c2
MD5 615363b6e1411b4b05835cd66559aefb
BLAKE2b-256 8924d6a00e02feef0983b4f50d8c844a19ef15a413c4263f8d3f4678e299c404

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page