Skip to main content

Convert regular expressions to minimized DFAs in AT&T FST format

Project description

regex2dfa

Convert regular expressions to minimized DFAs in AT&T FST format.

Pure Python · Zero dependencies · Results cached in memory

Installation

pip install regex2dfa

Usage

from regex2dfa import regex2dfa

dfa = regex2dfa("(a|b)+")
print(dfa)

Output:

0	1	97	97
0	1	98	98
1	1	97	97
1	1	98	98
1

Features

  • Pure Python — No external dependencies
  • Fast — Results cached with LRU (1024 entries)
  • Complete pipeline — Thompson's → Subset → Hopcroft minimization

Supported Syntax

Feature Syntax Example
Literal a abc
Any char . a.b
Character class [abc], [a-z], [^abc] [0-9]+
Quantifiers *, +, ? a*, b+, c?
Alternation | cat|dog
Grouping (...) (ab)+
Escapes \x00, \d, \w, \s, \C \xFF, \d+

Output Format

AT&T FST format with tab-separated fields:

  • Transitions: src dst input output
  • Final states: state_id

Labels are ASCII byte values (e.g., 97 = 'a').

Links

License

MIT

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

regex2dfa-0.2.1.tar.gz (14.8 kB view details)

Uploaded Source

Built Distribution

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

regex2dfa-0.2.1-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

File details

Details for the file regex2dfa-0.2.1.tar.gz.

File metadata

  • Download URL: regex2dfa-0.2.1.tar.gz
  • Upload date:
  • Size: 14.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for regex2dfa-0.2.1.tar.gz
Algorithm Hash digest
SHA256 4a82092ec04f7caa0216b9590c0fee7ee1b30337ce4ea6aeb9b6e7a46477c6e4
MD5 1674ff1542dd40f95171b87eb3148809
BLAKE2b-256 b5d15179e614d91f1c8da08a1bb9835612afbc4f5a1c95a9e855fa2683e2e4c8

See more details on using hashes here.

Provenance

The following attestation bundles were made for regex2dfa-0.2.1.tar.gz:

Publisher: publish.yml on kpdyer/regex2dfa

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file regex2dfa-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: regex2dfa-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 13.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for regex2dfa-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 eb225c630efeb6bf4bc4769e211e4923f63f81c5ba0b365ae887d167eaa9f463
MD5 3f8dc6b8b718ed38174a58e976c71868
BLAKE2b-256 a35312bc28e1c4edb7c3209883c16c0d54ab03b048bec4b392b3dd2500ce2c0e

See more details on using hashes here.

Provenance

The following attestation bundles were made for regex2dfa-0.2.1-py3-none-any.whl:

Publisher: publish.yml on kpdyer/regex2dfa

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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