Regex pattern matching and extraction library for Python.
Project description
pattex
A Python library for extracting common patterns from text using regex — emails, URLs, phone numbers, IP addresses, and more.
Installation
pip install pattex
Changelog
v0.3.0
pattex v0.3.0 brings a significant internal restructuring alongside new features and bug fixes.
Breaking / Structural
internet.pyhas been split intoemail_extractor.pyandurl_extractor.py. If you were importing directly from the internal module path, update your imports. Top-levelpatteximports are unaffected.
New Features
- URL Extraction —
extract_urls(text, mode),extract_urls_by_scheme(text, scheme), andextract_urls_by_domain(text, domain)are now available. Supports strict and permissive modes covering HTTP/S, FTP, WebSocket, IPv4, IPv6, bare domains, and localhost. - Gmail normalisation —
extract_gmail_emailsnow acceptsnormalize=Truewhich strips dots from the local part, unifies@googlemail.comto@gmail.com, and deduplicates canonical variants. is_valid_provider_email(email, provider)— single function to validate whether an email belongs to a given provider (gmail,yahoo,outlook,icloud,zoho,proton).
Bug Fixes
- Fixed
extract_emails_by_providerwhich was not dispatching to provider helper functions correctly — all six providers now route properly.
v0.3.1 - 2026-05-13
Fixed
- Zoho extractor: removed hyphen (
-) and plus (+) from allowed local part characters — Zoho usernames only permit letters, numbers, dots, and underscores per official documentation - Zoho extractor:
+is a subaddressing tag separator, not a valid account creation character; removed from base regex and validation logic - Proton extractor: tightened leading/trailing character rule — local part must
begin and end with an alphanumeric character (was checking against
._-set, now explicitly usesisalnum()to match Proton's documented rule)
Changed
- Renamed
email_extraction.py→email_extractor.py - Renamed
urls_extraction.py→url_extractor.py - Updated docstrings for
extract_zoho_emailsandextract_proton_emailsto reflect corrected provider rules - Added inline comments on each validation rule inside
email_extractor.pyfor all six provider extractors - Added documentation comments for all email regex patterns in
constants/regexes.pyand corresponding.pyistubs
Internal
- General code cleanups across extractor modules
Status
Currently under active development. Full documentation and usage examples coming soon.
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
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 pattex-0.3.1.tar.gz.
File metadata
- Download URL: pattex-0.3.1.tar.gz
- Upload date:
- Size: 19.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f35b2164f3219fbf2e4c3c33c21d0da927e6de35b4ce783fd9687c2aec87144b
|
|
| MD5 |
b82a878d670254424f18219c53cdc6c1
|
|
| BLAKE2b-256 |
73a8e5221ab60725b14c0214a3164a3ceaf5cac34d3c1b15577220b67747cb40
|
File details
Details for the file pattex-0.3.1-py3-none-any.whl.
File metadata
- Download URL: pattex-0.3.1-py3-none-any.whl
- Upload date:
- Size: 24.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
66630899f55ca3e271d5d2b9ec3eb1b3cc7b5b704def0e574b8638b99532b146
|
|
| MD5 |
c14221939fdfa4ff383f66ff4aa56096
|
|
| BLAKE2b-256 |
fb3213407f99ab25863ea9c57c59d7f97c028946c66aedb38ec3035db1218098
|