Skip to main content

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.

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.

Project details


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.3.0.tar.gz (24.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

interegular-0.3.0-py36-none-any.whl (23.6 kB view details)

Uploaded Python 3.6

File details

Details for the file interegular-0.3.0.tar.gz.

File metadata

  • Download URL: interegular-0.3.0.tar.gz
  • Upload date:
  • Size: 24.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0rc2

File hashes

Hashes for interegular-0.3.0.tar.gz
Algorithm Hash digest
SHA256 2aa753ce9fb8985464dcfc1e0d98a7cb6a8f451ca1c647f5359a0ab5de52d21e
MD5 dd1239b7e7b8969db81554b3919c74b1
BLAKE2b-256 95ba010ef5b6849d9d5cb55d8335b199fb5a9b9efd686fbbb86da174e214f7d6

See more details on using hashes here.

File details

Details for the file interegular-0.3.0-py36-none-any.whl.

File metadata

  • Download URL: interegular-0.3.0-py36-none-any.whl
  • Upload date:
  • Size: 23.6 kB
  • Tags: Python 3.6
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0rc2

File hashes

Hashes for interegular-0.3.0-py36-none-any.whl
Algorithm Hash digest
SHA256 db0f3b436a01d6dd439233ab7fae52ad4b0faa3da143f6583ecfd437470c5f8a
MD5 5c710f2f8e8d78123548b06612399e71
BLAKE2b-256 024b1de8a8a47f337aa9831de419015b4756e3bfeac2f30f073e92fcbe0fe576

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page