Skip to main content

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.py has been split into email_extractor.py and url_extractor.py. If you were importing directly from the internal module path, update your imports. Top-level pattex imports are unaffected.

New Features

  • URL Extractionextract_urls(text, mode), extract_urls_by_scheme(text, scheme), and extract_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 normalisationextract_gmail_emails now accepts normalize=True which strips dots from the local part, unifies @googlemail.com to @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_provider which 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 uses isalnum() to match Proton's documented rule)

Changed

  • Renamed email_extraction.pyemail_extractor.py
  • Renamed urls_extraction.pyurl_extractor.py
  • Updated docstrings for extract_zoho_emails and extract_proton_emails to reflect corrected provider rules
  • Added inline comments on each validation rule inside email_extractor.py for all six provider extractors
  • Added documentation comments for all email regex patterns in constants/regexes.py and corresponding .pyi stubs

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

pattex-0.3.1.tar.gz (19.2 kB view details)

Uploaded Source

Built Distribution

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

pattex-0.3.1-py3-none-any.whl (24.6 kB view details)

Uploaded Python 3

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

Hashes for pattex-0.3.1.tar.gz
Algorithm Hash digest
SHA256 f35b2164f3219fbf2e4c3c33c21d0da927e6de35b4ce783fd9687c2aec87144b
MD5 b82a878d670254424f18219c53cdc6c1
BLAKE2b-256 73a8e5221ab60725b14c0214a3164a3ceaf5cac34d3c1b15577220b67747cb40

See more details on using hashes here.

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

Hashes for pattex-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 66630899f55ca3e271d5d2b9ec3eb1b3cc7b5b704def0e574b8638b99532b146
MD5 c14221939fdfa4ff383f66ff4aa56096
BLAKE2b-256 fb3213407f99ab25863ea9c57c59d7f97c028946c66aedb38ec3035db1218098

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