Aller au contenu principal
ProduitsOutils de bureauTASTECADConsultation de plansTASTEFILESGestion de fichiersTASTEFTPTransfert de fichiersTASTESSHEspace de travail à distanceTASTEZIPCompression et extractionTASTEWINMGestion de fichiersOutils pour développeursTASTECODEEnvironnement de développement intégré pour RustTASTESTUDIOEnvironnement intégré de développement et de testTASTEETLIntégration de données (ETL)ServeursTASTEREMOTEServeur de bureau à distanceTASTEGEOServeur géospatialTASTEMAILEspace de travail e-mailInvestissementTASTESTOCKApplication de bureau de trading automatique d'actionsCommencerTéléchargementsDocumentationAcheterTous les produits
Marketplace
Actualités
TechActualitésL’actu dev du jourDocs développeursLangages de programmationRustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDartFrameworks front-end webNext.jsReactVue.js · NuxtSvelteKitAngularFrameworks serveurSpring BootDjangoFastAPIASP.NET CoreNestJS · ExpressFrameworks d'applications et de bureauTauriFlutterReact NativeElectronAlgorithmesBases des algorithmesAlgorithmes essentielsAlgorithmes avancésAlgorithmes pratiques
CommunautéProjetsJournaux de développementPromptsProblèmes d’outils d’IAVitrineGuide de la communauté
CollaborerTransfert techniqueRéalisation de site webRéalisation d'application de bureauChaîne de publication et de paiementPartenaire commercialContact
ServicesBureau à distancePaquets d'installation sur mesure
TASTEDEV
Produits

Outils de bureau

TASTECADDes plans complexes, ouverts en toute légèretéTASTEFILESSeulement les fichiers utiles, au plus viteTASTEFTPLe chemin le plus net pour vos fichiersTASTESSHEntre vos serveurs et vous, un lien plus solideTASTEZIPCompresser plus vite, extraire en toute sécuritéTASTEWINMUn gestionnaire de fichiers à deux volets, pensé pour le clavier

Outils pour développeurs

TASTECODEModifier, compiler, déboguer et tester vos apps Rust dans une seule fenêtreTASTESTUDIODe l’édition aux tests à distance et aux corrections IA approuvéesTASTEETLDéplacer les données, les valeurs sous les yeux

Serveurs

TASTEREMOTEUn bureau à distance hébergé sur votre propre serveurTASTEGEOUn serveur géospatial compatible GeoServer, reconstruit en RustTASTEMAILReprenez la maîtrise de vos e-mails

Investissement

TASTESTOCKDu trading automatique d'actions selon vos règles : quand, et quoi

Commencer

TéléchargementsDernières versions de chaque produitDocsUtiliser chaque produitAcheterAbonnements et licences perpétuellesTous les produitsTous les produits en un coup d’œil
Tous les produits
MarketplaceActualités
Tech

Actualités

L’actu dev du jourAnnonces officielles : langages, frameworks, GitHub et IADocs développeursGuides des langages, frameworks et algorithmes

Langages de programmation

RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDart

Frameworks

Frameworks front-end webNext.jsReactVue.js · NuxtSvelteKitAngular
Frameworks serveurSpring BootDjangoFastAPIASP.NET CoreNestJS · Express
Frameworks d'applications et de bureauTauriFlutterReact NativeElectron

Algorithmes

Bases des algorithmesAnalyse de complexité · Tri · Recherche · Structures de données de base · Arbres et tasAlgorithmes essentielsParcours de graphe · Plus courts chemins et arbres couvrants · Programmation dynamique · Algorithmes gloutons · Diviser pour régner · Backtracking (retour sur trace)Algorithmes avancésAlgorithmes sur les chaînes · Mathématiques et théorie des nombres · Manipulation de bits · Arbres de segments · Union-FindAlgorithmes pratiquesStratégie pour les entretiens de codage · Cache LRU · Limitation de débit · Hachage cohérent
Toute la documentation de développement
Communauté
ProjetsDécouvrir les créateurs et leurs travauxJournaux de développementDécisions et enseignementsPromptsInstructions réutilisablesProblèmes d’outils d’IAProblèmes et contournements de Claude, Codex, GeminiVitrineRéalisations terminéesGuide de la communautéConstruire en toute transparence
Collaborer
Transfert techniqueApplications natives en Rust et eguiRéalisation de site web10 langues, comptes, documentation et téléchargementsRéalisation d'application de bureauRust et egui, sans WebViewChaîne de publication et de paiementSignature, MSI, deb, rpm, AppImage, empreintesPartenaire commercialRecommandez-nous, touchez 30 %ContactDéveloppement, partenariats, investissement
Services
Bureau à distanceAccédez à votre ordinateur depuis le navigateurPaquets d'installation sur mesureSeulement l'utile, réglages préchargés
Acheter
FR
한국어EnglishDeutschEspañolFrançaisItalianoPortuguês (Brasil)日本語简体中文繁體中文
Se connecter
Se connecter
TASTEDEV

Des petits outils à un meilleur développement.

support@tastedev.netSoutenir TASTEDEV
ProduitsGamme de produitsAcheterDocsTéléchargementsMarketplaceAssistance
CommunautéProjetsJournaux de développementPromptsProblèmes d’outils d’IAVitrine
RèglesÀ proposPolitique de confidentialitéConditions d'utilisationConditions d’abonnementRemboursementRègles de la communauté
CompteSe connecterS'inscrire
Visiteurs
Aujourd’hui
Hier
Vues au total
Société
GXSOFT
Représentant
CHOI YOUNG GU
Numéro d’enregistrement
853-44-00368
Adresse
9F V24, 351 Gyeongin-ro, Michuhol-gu, Incheon, Republic of Korea
Téléphone
+82-10-4404-1523
E-mail
whitecalvin@tastedev.net
Responsable de la confidentialité
CHOI YOUNG GU

© 2026 TASTEDEVLes informations produit s'appuient sur des sources de développement vérifiées.Publié · en amélioration

Documentation Algorithmes sur les chaînes
Algorithmes sur les chaînes
ConceptsHow It WorksImplementationComplexityPractice ProblemsReal-World Use
Discussions

Guide Algorithmes sur les chaînes · 6/6

Real-World Use

Ce chapitre n'est disponible qu'en anglais pour le moment.

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)
Des questions sur ce chapitre ?
Chapitre précédentPractice Problems

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)

0 commentaire

Meilleurs commentairesPlus récents d'abord

Se connecter · Connectez-vous pour laisser un commentaire.