Registry / data / trieregex

trieregex

JSON →
library1.0.0pypypi✓ verified 81d ago

TrieRegex builds trie-based regular expressions from large word lists, enabling fast string matching against many patterns. Current version 1.0.0 requires Python >=3.6 and is released on PyPI. The library has a stable API with no recent breaking changes.

pip install trieregex
INSTALL
IMPORT
SIG · TRIEREGEX
T
trieregex
datapythonv1.0.0
Install
2.6s avg
Import
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.0.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 19.3MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.6s · import 0.000s · 20MB
17MB installed
● package 17MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

TrieRegEx
from trieregex import TrieRegEx
from trieregex import Trie

Create a trie from a list of words and compile a regex pattern.

from trieregex import Trie words = ['foo', 'bar', 'foobar'] trie = Trie() trie.add_all(words) pattern = trie.regex() print(pattern) # Output: (?:bar|foo(?:bar)?) # Pattern can be used with re module import re result = re.search(pattern, 'foobar is here') if result: print(result.group()) # Output: foobar
Debug
Known issues
gotchaTrie.regex() returns a non-capturing group (?: instead of capturing parentheses. If you need to capture the matched word, use Trie.capturing_groups() or wrap the pattern.
fix
Use trie.capturing_groups() or manually add parentheses around pattern.
affects: all
gotchaTrie does not automatically escape special regex characters in input words. If words contain characters like '.', '*', etc., the resulting regex may have unintended meta-meaning.
fix
Preprocess words with re.escape() before adding them, or use Trie.add() with pre-escaped strings.
affects: all
deprecatedThe method Trie.get_regex() is deprecated since version 0.9.3 in favor of Trie.regex() but still works.
fix
Use Trie.regex() instead.
affects: >=0.9.3,<1.1.0
Upgrade
Version history
1.0.0latest on PyPI · released Jun 23, 2020
Audit
Dependencies
regexoptionalOptional dependency for advanced regex features if needed
Agent activity
28 hits · last 30 days
node
26
OpenAI (training)
1
Resources
trieregex — pip install trieregex · libregistry