a regex intersection checker
Project description
Interegular
regex intersection checker
A library to check a subset of python regexes for intersections. Based on grennery by @qntm. Adapted for lark-parser
Note: due to the use of annotations/dataclasses, this package is not backwards compatible with python versions <=3.5. Since this is a small fraction of users, I am choosing to ignore that 'problem'.
Interface
Function | Usage |
---|---|
compare_regexes(*regexes: str) |
Takes a series of regexes as strings and returns a Generator of all intersections as (str, str) |
parse_pattern(regex: str) |
Parses a regex as string to a Pattern object |
interegular.compare_patterns(*patterns: Pattern) |
Takes a series of regexes as patterns and returns a Generator of all intersections as (Pattern, Pattern) |
Pattern |
A class representing a parsed regex (intermediate representation) |
REFlags |
A enum representing the flags a regex can have |
FSM |
A class representing a fully parsed regex. (Has many useful members) |
Pattern.with_flags(added: REFlags, removed: REFlags) |
A function to change the flags that are applied to a regex |
Pattern.to_fsm() -> FSM |
A function to create a FSM object from the Pattern |
Comparator |
A Class to compare a group of Patterns |
What is supported?
Most normal python-regex syntax is support. But because of the backend that is used (final-state-machines), some things can not be implemented. This includes:
- Backwards references (
\1
,(?P=open)
) - Conditional Matching (
(?(1)a|b)
) - Some cases of lookaheads/lookbacks (You gotta try out which work and which don't)
- A word of warning: This is currently not correctly handled, and some things might parse, but not work correctly. I am currently working on this.
Some things are simply not implemented and will implemented in the future:
- Some flags (Progress:
ims
fromaiLmsux
) - Some cases of lookaheads/lookbacks (You gotta try out which work and which don't)
TODO
- Docs
- More tests
- Checks that the syntax is correctly handled.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
interegular-0.2.5.tar.gz
(23.1 kB
view hashes)
Built Distribution
Close
Hashes for interegular-0.2.5-py36-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 523acf23e29590c588f15b8f22c424ef9f3b2efa02db3ed212f7817c0f80e55d |
|
MD5 | 93b115aa1f302122f5324e1fefc8851d |
|
BLAKE2b-256 | bdb6413e961aa34689d592bde2abefa0c323d89befe82e8eba82cea217b71780 |