Registry / serialization / commonregex

commonregex

JSON →
library1.5.4pypypi✓ verified 86d ago

CommonRegex is a Python library that bundles a collection of commonly used regular expressions with a straightforward API. It simplifies the extraction of various patterns like dates, times, emails, phone numbers, links, IP addresses, prices, and street addresses from text strings. The current version is 1.5.4, released in 2014, indicating a maintenance-only cadence without active development.

pip install commonregex
INSTALL
IMPORT
SIG · COMMONREGEX
C
commonregex
serializationpythonv1.5.4
Install
2.4s avg
Import
65ms
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.5.4 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.915 runs
installs and imports cleanly · install 0.0s · import 0.067s · 19.2MB
glibc
py 3.103.915 runs
installs and imports cleanly · install 2.4s · import 0.063s · 20MB
17MB installed
● package 17MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

CommonRegex
from commonregex import CommonRegex
import commonregex
The primary interface is the CommonRegex class, not the module directly.
date (or other individual regex patterns)
from commonregex import date
from commonregex.regexes import date
Individual regex patterns are exposed directly under the top-level commonregex module.

Instantiate the `CommonRegex` class with the text to be parsed. Extracted patterns can then be accessed as attributes (e.g., `parsed_text.dates`). For new texts, you can either create a new instance or call the corresponding method on an existing instance.

from commonregex import CommonRegex text = """John, please get that article on www.linkedin.com to me by 5:00PM on Jan 9th 2012. 4:00 would be ideal, actually. If you have any questions, You can reach me at (519)-236-2723x341 or get in touch with my associate at harold.smith@gmail.com. Check my IP 192.168.1.1.""" # Instantiate CommonRegex with the text parsed_text = CommonRegex(text) # Access extracted data via attributes print(f"Dates: {parsed_text.dates}") print(f"Times: {parsed_text.times}") print(f"Links: {parsed_text.links}") print(f"Phones with Exts: {parsed_text.phones_with_exts}") print(f"Emails: {parsed_text.emails}") print(f"IPs: {parsed_text.ips}") # Alternatively, use a single instance for multiple texts parser = CommonRegex() print(f"Later time: {parser.times('Meet me at 7:30 AM.')}")
Debug
Known issues
gotchaThe module is explicitly noted as "English/US specific". Its regular expressions are tailored for English-language patterns and US formats (e.g., phone numbers, dates), and may not work as expected for other languages or regional formats.
fix
Review the source code's regex patterns (`commonregex.py`) if you need to adapt them for non-English or non-US specific text, or consider alternative libraries.
affects: All versions
gotchaPerformance may be a concern for large texts or high-volume processing. Community-maintained forks like 'commonregex-improved' highlight that the original library's API calls can be slow due to how regular expressions are compiled and executed internally.
fix
For performance-critical applications, consider using 'commonregex-improved' (PyPI: `crim`) or manually compiling and reusing `re` patterns from `commonregex` if specific patterns are needed.
affects: All versions
gotchaSome individual regex patterns, when used directly with `re.findall`, might produce partial matches or require additional surrounding conditions for strict validation (e.g., `ip` regex matching parts of other numbers).
fix
When using the raw regex patterns (e.g., `from commonregex import ip`), ensure you validate the results against your specific requirements or add word boundaries (e.g., `\b`) to the patterns if not already present, for stricter matching.
affects: All versions
Errors
Common errors & fixes
AttributeError: 'CommonRegex' object has no attribute 'dates()'
When `CommonRegex` is initialized with text (e.g., `parsed_text = CommonRegex(text)`), the results for that specific text are exposed as attributes (e.g., `parsed_text.dates`), not methods. Users incorrectly try to call them as methods.
fix
Access the extracted data as an attribute, e.g., `parsed_text.dates`. If you want to process *new* text with an existing `CommonRegex` instance, you would use methods like `parser.dates('new text here')`.
ImportError: cannot import name 'commonregex' from 'commonregex' (unknown location)
Users attempting to import the `commonregex` module itself as a class or specific function, similar to `from some_lib import some_lib`.
fix
To import the main parsing class, use `from commonregex import CommonRegex`. To import individual regex patterns, use `from commonregex import date` (or `email`, `time`, etc.).
No matches found or incorrect matches for non-English text.
The regular expressions within `commonregex` are designed specifically for English/US linguistic and formatting conventions. They will fail or produce unexpected results when applied to text in other languages or different regional formats.
fix
This library is not suitable for non-English or non-US specific content without significant modification of its internal regex patterns. Consider using a library designed for internationalization or writing custom regexes for your target language/locale.
Upgrade
Version history
1.5.4latest on PyPI
Audit
Dependencies

No dependency data recorded yet.

Agent activity
13 hits · last 30 days
node
8
OpenAI (training)
1
Resources
commonregex — pip install commonregex · libregistry