textsearch
Find strings/words in text; convenience and C speed
What it is and what it does
textsearch is a Python library for finding and replacing multiple strings in text with word-boundary awareness. It wraps the C-based Aho-Corasick automaton (via pyahocorasick) to deliver speed gains over regex while offering convenience features like case-sensitivity modes, custom return types, and handler hooks for post-match processing. It is designed for NLP and text-processing tasks where you need to match full words rather than substrings, and where performance matters.
The library supports multiple case modes (ignore, insensitive, sensitive, smart), flexible return types (matched string, normalized value, or custom objects), and optional accent-character normalization. It depends on anyascii for character normalization and pyahocorasick for the underlying automaton. However, the project is no longer maintained—the last commit was in September 2022—so it will not receive updates for new Python versions or security issues.
Use it for:
- Build a tokenizer that finds known terms in documents while respecting word boundaries, returning normalized labels.
- Implement a spell-checker or text normalizer that replaces contractions or misspellings in bulk across large text corpora.
- Create a keyword extraction tool that identifies multiple domain-specific terms in documents with case-insensitive matching.
- Refactor code or configuration files by replacing multiple strings in one pass, with regex-like prefix/postfix boundary support.
- Normalize text by replacing accented characters or synonyms across a corpus faster than regex-based approaches.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Find and replace multiple strings in text with word-boundary awareness, using C-accelerated Aho-Corasick matching for speed comparable to regex but typically 30-100x faster.
Yes, if you need fast multi-string matching with word boundaries and can tolerate an unmaintained library. The low install friction and permissive license make adoption easy, and the performance claims are compelling for NLP tasks. However, verify that pyahocorasick works on your target platform and Python version, and accept that no updates will arrive for compatibility or security issues. For new projects, consider whether an actively maintained alternative better suits your risk tolerance.
Install
textsearch on PyPI
pip
pip install textsearchuv
uv add textsearchpoetry
poetry add textsearchInstalling textsearch
Before you install
Low friction: pure wheel distribution with only two runtime dependencies (anyascii and pyahocorasick). However, maintenance is abandoned—last release was 2022-09-02 and no commits since then, so security or compatibility issues would not be addressed.
License in practice
MIT license is permissive, allowing commercial and private use with minimal restrictions.
Quickstart
pip install textsearch
from textsearch import TextSearch
ts = TextSearch(case="ignore", returns="norm")
ts.add("hi", "HI")
ts.findall("hi there") # Returns ["HI"]
Verify before relying
- Whether pyahocorasick's compiled dependency works reliably on all modern platforms and Python versions.
- Current compatibility with Python versions beyond 3.7 (classifiers list only up to 3.7).
- Whether the 30-100x speedup claim has been validated against modern regex engines or competing libraries.
Package facts
| License | MIT (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — anyascii, pyahocorasick |
| Maintenance | abandoned — 1,442 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 608,680/month — #5,778 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: textsearch-0.0.24-py2.py3-none-any.whl
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
contractionsExpands English contractions and slang into…
permissive · top 15,000 on PyPI
flashtextExtracts or replaces keywords in text using the…
permissive · top 5,000 on PyPI
ahocorapyahocorapy implements the Aho-Corasick algorithm…
permissive · top 15,000 on PyPI
codespellCodespell finds and fixes common misspellings…
copyleft · top 5,000 on PyPI
multiregexMatches multiple regex patterns against a…
permissive · top 15,000 on PyPI
tfidf-matcherPerforms fast fuzzy string matching on large…
permissive · top 15,000 on PyPI
retrieBuilds efficient Trie-based regex patterns for…
permissive · top 15,000 on PyPI
pyspellcheckerDetects misspelled words and suggests…
permissive · top 5,000 on PyPI
better-profanityDetects and censors profanity in text,…
permissive · top 5,000 on PyPI