Skip to main content
ProductsDesktop toolsTASTECADDrawing reviewTASTEFILESFile managementTASTEFTPFile transferTASTESSHRemote workspaceTASTEZIPCompression and extractionTASTEWINMFile managementDeveloper toolsTASTECODERust integrated development environmentTASTESTUDIOIntegrated development and test environmentTASTEETLData integration (ETL)ServersTASTEREMOTERemote desktop serverTASTEGEOGeospatial serverTASTEMAILMail workspaceInvestingTASTESTOCKStock auto-trading desktop appGet startedDownloadsDocumentationBuyAll products
Marketplace
News
TechNewsToday's dev newsDeveloper docsProgramming languagesRustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDartWeb front-end frameworksNext.jsReactVue.js · NuxtSvelteKitAngularServer frameworksSpring BootDjangoFastAPIASP.NET CoreNestJS · ExpressApp & desktop frameworksTauriFlutterReact NativeElectronAlgorithmsAlgorithm basicsCore algorithmsAdvanced algorithmsPractical algorithms
CommunityProjectsDevelopment logsPromptsAI tool issuesShowcaseCommunity guide
Work with usTech transferWebsite buildDesktop app buildRelease and payment pipelineSales partnerContact
ServicesRemote desktopCustom installer packages
TASTEDEV
Products

Desktop tools

TASTECADComplex drawings, opened with easeTASTEFILESJust the files you need, as fast as possibleTASTEFTPThe tidiest path for your filesTASTESSHA stronger link between you and your serversTASTEZIPPack faster, unpack saferTASTEWINMA keyboard-first file manager with two panes

Developer tools

TASTECODEEdit, build, debug and test Rust apps in one windowTASTESTUDIOFrom editing to remote tests and approved AI fixesTASTEETLMove data while you watch the values

Servers

TASTEREMOTEA remote desktop you run on your own serverTASTEGEORebuilding a GeoServer-compatible geospatial server in RustTASTEMAILTake back control of your email

Investing

TASTESTOCKStock auto-trading that follows the rules you set: when, and what

Get started

DownloadsLatest builds of every productDocsHow to use each productBuySubscriptions and perpetual licencesAll productsEvery product at a glance
All products
MarketplaceNews
Tech

News

Today's dev newsOfficial announcements on languages, frameworks, GitHub and AIDeveloper docsGuides to languages, frameworks and algorithms

Programming languages

RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDart

Frameworks

Web front-end frameworksNext.jsReactVue.js · NuxtSvelteKitAngular
Server frameworksSpring BootDjangoFastAPIASP.NET CoreNestJS · Express
App & desktop frameworksTauriFlutterReact NativeElectron

Algorithms

Algorithm basicsComplexity analysis · Sorting · Searching · Basic data structures · Trees and heapsCore algorithmsGraph traversal · Shortest paths & minimum spanning trees · Dynamic programming · Greedy algorithms · Divide and conquer · BacktrackingAdvanced algorithmsString algorithms · Math and number theory · Bit manipulation · Segment trees · Union-findPractical algorithmsCoding interview strategy · LRU cache · Rate limiting · Consistent hashing
All development docs
Community
ProjectsDiscover builders and their workDevelopment logsDecisions and lessons learnedPromptsReusable instructionsAI tool issuesProblems and workarounds for Claude, Codex, GeminiShowcaseFinished resultsCommunity guideHow we build in the open
Work with us
Tech transferNative apps in Rust and eguiWebsite build10 languages, accounts, docs and downloadsDesktop app buildRust and egui, no WebViewRelease and payment pipelineSigning, MSI, deb, rpm, AppImage, hashesSales partnerRecommend us and earn 30%ContactBuilds, partnerships and investment
Services
Remote desktopReach your computer from a browserCustom installer packagesOnly the features you need, settings preloaded
Buy
EN
한국어EnglishDeutschEspañolFrançaisItalianoPortuguês (Brasil)日本語简体中文繁體中文
Log in
Log in
TASTEDEV

From small tools to better development.

support@tastedev.netSupport TASTEDEV
ProductsProduct lineupBuyDocsDownloadsMarketplaceSupport
CommunityProjectsDevelopment logsPromptsAI tool issuesShowcase
PoliciesAbout usPrivacy policyTerms of serviceSubscription termsRefund policyCommunity guidelines
AccountLog inSign up
Visitors
Today
Yesterday
Total views
Company
GXSOFT
Representative
CHOI YOUNG GU
Business registration number
853-44-00368
Address
9F V24, 351 Gyeongin-ro, Michuhol-gu, Incheon, Republic of Korea
Phone
+82-10-4404-1523
Email
whitecalvin@tastedev.net
Privacy officer
CHOI YOUNG GU

© 2026 TASTEDEVProduct information is based on verified development sources.Released · improving

String algorithms docs
String algorithms
ConceptsHow It WorksImplementationComplexityPractice ProblemsReal-World Use
Discussions

String algorithms guide · 6/6

Real-World Use

Most string algorithms you rely on live inside libraries and tools. This chapter shows where, and which traps to avoid when writing your own.

String algorithms in real systems

  • Standard library search: CPython's str.find and in are built on a simplified Boyer-Moore-Horspool scheme, and since Python 3.10 long needles use the Crochemore-Perrin Two-Way algorithm. glibc's memmem and strstr also use Two-Way for long needles. Two-Way guarantees linear worst-case time with only constant extra memory.
  • grep-style tools: GNU grep combines Boyer-Moore style search with algorithms for matching many keywords at once. ripgrep builds on the Rust crates aho-corasick and memchr, which provide multi-pattern search and SIMD acceleration.
  • Intrusion detection and antivirus: thousands of signatures must be found in packets or files in a single pass, so Aho-Corasick and its variants are common.
  • File sync and deduplication: rsync uses a rolling checksum to find which blocks changed and sends only those. Backup tools use rolling hashes such as Rabin fingerprints to pick content-defined chunk boundaries.
  • Plagiarism detection: documents are turned into hashes of k-grams, and the winnowing technique keeps a subset of them as a fingerprint.
  • Routing and dictionaries: longest-prefix matching in IP routing uses trie variants; the Linux kernel's IPv4 routing table is an LC-trie. Search-box autocomplete, spelling dictionaries and prefix queries in key-value stores also use tries or radix trees.
  • Bioinformatics: tools that align short reads to a reference genome index the huge text with suffix arrays and BWT-based FM-indexes.

Pitfall 1: Unicode

Languages count string length and positions in different units.

EnvironmentIndex unitLength of "😀"
Python strcode point1
Java String, JavaScriptUTF-16 code unit2
C++ std::string, Rust str::lenUTF-8 byte4

Pass a position computed in Java or JavaScript to a Python service and it will be off as soon as the text contains an emoji. When positions cross an API boundary, state the unit explicitly.

const s = "a😀b";
console.log(s.length);            // 4 (UTF-16 code units)
console.log([...s].length);       // 3 (code points)
const seg = new Intl.Segmenter("en", { granularity: "grapheme" });
console.log([...seg.segment("👍🏽")].length); // 1 (user-perceived character)

The same character can also be encoded in more than one way. é may be a single precomposed code point (U+00E9) or e followed by a combining accent. Text stored in NFD, as macOS file names often are, will not match an NFC query. For case-insensitive comparison, casefold() is more correct than lower().

import unicodedata

nfd = unicodedata.normalize("NFD", "café")
print(len("café"), len(nfd))                           # 4 5
print("café" in nfd)                                   # False
print("café" in unicodedata.normalize("NFC", nfd))     # True
print("Straße".lower() == "STRASSE".lower())          # False
print("Straße".casefold() == "STRASSE".casefold())    # True

A search pipeline should apply the same normalization and case folding when indexing and when querying.

Pitfall 2: hash collisions and hostile input

If Rabin-Karp skips the confirmation step on a hash hit, it can report wrong answers. With a fixed base and modulus an attacker can build colliding inputs, so pick a random base on each run and use a large prime modulus such as 2^61 - 1, or combine two independent hashes.

import random

MOD = (1 << 61) - 1
BASE = random.randrange(256, MOD - 1)   # different base on every run


def poly_hash(s: str) -> int:
    h = 0
    for ch in s:
        h = (h * BASE + ord(ch)) % MOD
    return h


print(poly_hash("abc") == poly_hash("abc"), poly_hash("abc") == poly_hash("acb"))
# True False (a collision is very unlikely, but never impossible)

Pitfall 3: memory and recursion

  • Tries allocate many node objects and use a lot of memory. With millions of words, consider compact structures: radix trees, double-array tries, or a sorted list with binary search.
  • A recursive DFS over a trie can hit Python's recursion limit on very long keys. Use an explicit stack.
  • Regular expressions are convenient, but on backtracking engines patterns like (a+)+ can take exponential time (ReDoS). Escape user input with re.escape before using it as a pattern.

What to pick

SituationRecommendation
One simple searchThe language's built-ins (in, find, indexOf)
Need borders, periods or prefix dataPrefix function (KMP) or Z-array
Many patterns of equal length, substring comparisonRolling hash
Thousands of patterns of varying lengthAn Aho-Corasick library
Prefix lookup in a dictionary, autocompleteTrie, or sorted list plus binary search
Many queries over one large textSuffix array, FM-index, a search engine

Summary

  • Libraries and tools use Two-Way, Boyer-Moore, Aho-Corasick, rolling hashes and tries depending on the job.
  • With Unicode, agree on index units, normalization and case folding first.
  • Defend against hash collisions with a random base and a confirmation step, and consider compact structures for large dictionaries.

Further reading

  • String-searching algorithm (Wikipedia)
  • Prefix function. Knuth-Morris-Pratt (cp-algorithms)
  • Z-function and its calculation (cp-algorithms)
  • String Hashing (cp-algorithms)
  • Trie (Wikipedia)
  • Aho-Corasick algorithm (Wikipedia)
  • Unicode HOWTO (Python docs)
Questions about this chapter?
Previous chapterPractice Problems

0 comments

Top commentsNewest first

Sign in · Sign in to leave a comment.