Interegular is a Python library designed to check a subset of Python regular expressions for intersections. Currently at version 0.3.3, it focuses on speed and compatibility with Python's `re` module syntax, differentiating itself from libraries like `greenery` by prioritizing performance over regex reconstruction from Finite State Machines (FSMs). The project appears to have an active development status, with updates released on an irregular cadence. [1, 2, 3]
pip install interegularVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to use `interegular.compare_regexes` to find intersections between multiple regular expression strings and `compare_patterns` for pre-parsed `Pattern` objects. It shows cases with and without common matches. [1, 2, 3]
Avoid using unsupported regex features. Test complex patterns thoroughly to ensure correct behavior. Consider simplifying regexes if unexpected results occur.
Check the `REFlags` enum for supported flags. If a crucial flag is missing, you might need to preprocess your regex or adjust your logic to not depend on that flag.
Ensure your `lark` parser configuration, if used directly, specifies a `basic` or `contextual` lexer for compatibility with `interegular`.
Be aware that lazy quantifiers will behave greedily. Adjust your regexes to achieve the desired effect without relying on non-greedy semantics, or accept the greedy interpretation when using `interegular`.
Simplify the regular expression by removing or rewriting unsupported constructs. Consult the `interegular` documentation for supported regex syntax.
Simplify the regular expression, break down complex patterns into smaller, manageable parts, or redesign the logic to avoid overly complex regexes that generate excessively large FSMs.
Avoid using case-insensitive flags with problematic Unicode characters or manually handle the case sensitivity for such characters within your regex if possible. A specific fix for this issue might require a patched version of the library as indicated in some discussions.
Carefully review the regular expression string for any syntax errors, unclosed groups, or unsupported features. Ensure the regex strictly adheres to the subset of Python `re` syntax that `interegular` is designed to handle.