Skip to main content

Interegular

regex intersection checker

A library to check a subset of python regexes for intersections. Based on grennery by @qntm. Adapted for lark-parser.

The primary difference with grennery library is that interegular is focused on speed and compatibility with python re syntax, whereas grennery has a way to reconstruct a regex from a FSM, which interegular lacks.

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 from aiLmsux)
  • 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.

Release files for interegular 0.3.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for interegular 0.3.3
File Size Uploaded
interegular-0.3.3.tar.gz 24.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for interegular 0.3.3
File Interpreter ABI Platform
interegular-0.3.3-py37-none-any.whl Python 3.7 none any Details

Total release size: 48.3 kB

Release files / interegular-0.3.3.tar.gz

Download URL interegular-0.3.3.tar.gz
Size 24.7 kB
Tags Source
SHA-256 checksum
How to use checksums
d9b697b21b34884711399ba0f0376914b81899ce670032486d0d048344a76600
BLAKE2b-256 checksum
How to use checksums
dc9d8b6dde58a028a3962ce17e84d5fe73758df61378e00ef8ac3d85da34b0ff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.0rc2

Release files / interegular-0.3.3-py37-none-any.whl

Download URL interegular-0.3.3-py37-none-any.whl
Size 23.6 kB
Tags Python 3.7
SHA-256 checksum
How to use checksums
b0c07007d48c89d6d19f7204972d369b2a77222722e126b6aa63aa721dc3b19c
BLAKE2b-256 checksum
How to use checksums
c40172d6472f80651673716d1deda2a5bbb633e563ecf94f4479da5519d69d25
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.0rc2

Release history Release notifications | RSS feed

This release

0.3.3 This release

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.8

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page