{"id":8906,"library":"commonregex","title":"CommonRegex","description":"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.","status":"maintenance","version":"1.5.4","language":"en","source_language":"en","source_url":"https://github.com/madisonmay/CommonRegex","tags":["regex","parsing","text processing","data extraction","regular expressions"],"install":[{"cmd":"pip install commonregex","lang":"bash","label":"Install with pip"}],"dependencies":[],"imports":[{"note":"The primary interface is the CommonRegex class, not the module directly.","wrong":"import commonregex","symbol":"CommonRegex","correct":"from commonregex import CommonRegex"},{"note":"Individual regex patterns are exposed directly under the top-level commonregex module.","wrong":"from commonregex.regexes import date","symbol":"date (or other individual regex patterns)","correct":"from commonregex import date"}],"quickstart":{"code":"from commonregex import CommonRegex\n\ntext = \"\"\"John, please get that article on www.linkedin.com to me by 5:00PM on Jan 9th 2012.\n4:00 would be ideal, actually. If you have any questions, You can reach me at (519)-236-2723x341\nor get in touch with my associate at harold.smith@gmail.com. Check my IP 192.168.1.1.\"\"\"\n\n# Instantiate CommonRegex with the text\nparsed_text = CommonRegex(text)\n\n# Access extracted data via attributes\nprint(f\"Dates: {parsed_text.dates}\")\nprint(f\"Times: {parsed_text.times}\")\nprint(f\"Links: {parsed_text.links}\")\nprint(f\"Phones with Exts: {parsed_text.phones_with_exts}\")\nprint(f\"Emails: {parsed_text.emails}\")\nprint(f\"IPs: {parsed_text.ips}\")\n\n# Alternatively, use a single instance for multiple texts\nparser = CommonRegex()\nprint(f\"Later time: {parser.times('Meet me at 7:30 AM.')}\")","lang":"python","description":"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."},"warnings":[{"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.","message":"The 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.","severity":"gotcha","affected_versions":"All versions"},{"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.","message":"Performance 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.","severity":"gotcha","affected_versions":"All versions"},{"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.","message":"Some 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).","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"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')`.","cause":"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.","error":"AttributeError: 'CommonRegex' object has no attribute 'dates()'"},{"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.).","cause":"Users attempting to import the `commonregex` module itself as a class or specific function, similar to `from some_lib import some_lib`.","error":"ImportError: cannot import name 'commonregex' from 'commonregex' (unknown location)"},{"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.","cause":"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.","error":"No matches found or incorrect matches for non-English text."}]}