{"id":24734,"library":"trieregex","title":"TrieRegex","description":"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.","status":"active","version":"1.0.0","language":"python","source_language":"en","source_url":"https://github.com/ermanh/trieregex","tags":["trie","regex","pattern-matching","string-matching"],"install":[{"cmd":"pip install trieregex","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Optional dependency for advanced regex features if needed","package":"regex","optional":true}],"imports":[{"note":"Main class for building trie regex","symbol":"Trie","correct":"from trieregex import Trie"}],"quickstart":{"code":"from trieregex import Trie\n\nwords = ['foo', 'bar', 'foobar']\ntrie = Trie()\ntrie.add_all(words)\npattern = trie.regex()\nprint(pattern)  # Output: (?:bar|foo(?:bar)?)\n# Pattern can be used with re module\nimport re\nresult = re.search(pattern, 'foobar is here')\nif result:\n    print(result.group())  # Output: foobar","lang":"python","description":"Create a trie from a list of words and compile a regex pattern."},"warnings":[{"fix":"Use trie.capturing_groups() or manually add parentheses around pattern.","message":"Trie.regex() returns a non-capturing group (?:\n instead of capturing parentheses. If you need to capture the matched word, use Trie.capturing_groups() or wrap the pattern.\n","severity":"gotcha","affected_versions":"all"},{"fix":"Preprocess words with re.escape() before adding them, or use Trie.add() with pre-escaped strings.","message":"Trie does not automatically escape special regex characters in input words. If words contain characters like '.', '*', etc., the resulting regex may have unintended meta-meaning.\n","severity":"gotcha","affected_versions":"all"},{"fix":"Use Trie.regex() instead.","message":"The method Trie.get_regex() is deprecated since version 0.9.3 in favor of Trie.regex() but still works.\n","severity":"deprecated","affected_versions":">=0.9.3,<1.1.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use trie.regex() instead of trie.get_regex().","cause":"Code uses deprecated method removed in very old version (pre-0.9.3) or newer version.","error":"AttributeError: 'Trie' object has no attribute 'get_regex'"},{"fix":"Use trie.add_all(list) to add multiple words, or iterate over list calling add().","cause":"Passing a list to trie.add(list) instead of iterating.","error":"TypeError: add() missing 1 required positional argument: 'word'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}