本文へスキップ
製品デスクトップツールTASTECAD図面の確認TASTEFILESファイル管理TASTEFTPファイル転送TASTESSHリモートワークスペースTASTEZIP圧縮と展開TASTEWINMファイル管理開発ツールTASTECODERust 統合開発環境TASTESTUDIO統合開発・テスト環境TASTEETLデータ統合(ETL)サーバーTASTEREMOTEリモートデスクトップサーバーTASTEGEO空間情報サーバーTASTEMAILメールワークスペース投資TASTESTOCK株式自動売買デスクトップアプリはじめるダウンロードドキュメント購入すべての製品
マーケットプレイス
ニュース
技術ニュース今日の開発ニュース開発ドキュメントプログラミング言語RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDartWebフロントエンド フレームワークNext.jsReactVue.js · NuxtSvelteKitAngularサーバー フレームワークSpring BootDjangoFastAPIASP.NET CoreNestJS · Expressアプリ・デスクトップ フレームワークTauriFlutterReact NativeElectronアルゴリズムアルゴリズムの基礎主要アルゴリズム発展アルゴリズム実務のアルゴリズム
コミュニティプロジェクト開発ログプロンプトAIツールの問題ショーケースコミュニティガイド
協業技術移転ウェブサイト構築デスクトップアプリ構築リリース・決済パイプライン販売パートナーお問い合わせ
サービスリモートデスクトップインストールパッケージのカスタマイズ
TASTEDEV
製品

デスクトップツール

TASTECAD複雑な図面を、軽やかにひらくTASTEFILES必要なファイルだけを、最速でTASTEFTPファイルが行き交う、いちばん端正な道TASTESSHサーバーとあなたを、より確かにつなぐTASTEZIPより速くまとめ、より安全にひらくTASTEWINM2つの画面で整理する、キーボード中心のファイルマネージャー

開発ツール

TASTECODERust アプリの編集・ビルド・デバッグ・テストまでひとつのウィンドウでTASTESTUDIO編集からリモートテスト、承認した AI 修正までTASTEETL値を見ながら、データを運ぶ

サーバー

TASTEREMOTE自社サーバーで運用するリモートデスクトップTASTEGEOGeoServer 互換の空間情報サーバーを Rust で作り直しますTASTEMAILメールの主導権を、もう一度自分の手に

投資

TASTESTOCKいつ・何を。自分で決めたルールどおりに動く株式自動売買

はじめる

ダウンロード全製品の最新版ドキュメント各製品の使い方購入サブスクリプション・永久ライセンスすべての製品全製品を一覧で
すべての製品
マーケットプレイスニュース
技術

ニュース

今日の開発ニュース言語・フレームワーク・GitHub・AI の公式発表開発ドキュメント言語・フレームワーク・アルゴリズムのガイド

プログラミング言語

RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDart

フレームワーク

Webフロントエンド フレームワークNext.jsReactVue.js · NuxtSvelteKitAngular
サーバー フレームワークSpring BootDjangoFastAPIASP.NET CoreNestJS · Express
アプリ・デスクトップ フレームワークTauriFlutterReact NativeElectron

アルゴリズム

アルゴリズムの基礎計算量解析 · ソート · 探索 · 基本データ構造 · 木構造とヒープ主要アルゴリズムグラフ探索 · 最短経路と最小全域木 · 動的計画法 · 貪欲法 · 分割統治法 · バックトラッキング発展アルゴリズム文字列アルゴリズム · 数学と整数論 · ビット演算 · セグメント木 · Union-Find実務のアルゴリズムコーディング面接対策 · LRUキャッシュ · レート制限 · コンシステントハッシュ法
開発ドキュメントをすべて見る
コミュニティ
プロジェクトビルダーと作品を探す開発ログ決定と試行錯誤プロンプト再利用できる指示AIツールの問題Claude・Codex・Gemini の問題と回避策ショーケース完成した成果コミュニティガイドオープンにつくる方法
協業
技術移転Rust・egui でネイティブアプリを作るウェブサイト構築10言語、アカウント、ドキュメントとダウンロードデスクトップアプリ構築Rust・egui、WebView なしリリース・決済パイプライン署名・MSI・deb・rpm・AppImage・ハッシュ販売パートナー紹介して決済額の30%お問い合わせ構築・提携・投資のご相談
サービス
リモートデスクトップブラウザから自分のパソコンへインストールパッケージのカスタマイズ必要な機能だけ、設定は事前に
購入
JA
한국어EnglishDeutschEspañolFrançaisItalianoPortuguês (Brasil)日本語简体中文繁體中文
ログイン
ログイン
TASTEDEV

小さなツールから、より良い開発へ。

support@tastedev.netTASTEDEVを支援
製品製品ラインナップ購入ドキュメントダウンロードマーケットプレイスサポート
コミュニティプロジェクト開発ログプロンプトAIツールの問題ショーケース
ポリシー会社概要プライバシーポリシー利用規約サブスクリプション規約返金ポリシーコミュニティガイドライン
アカウントログイン新規登録
訪問者
今日
昨日
累計閲覧
商号
GXSOFT
代表者
CHOI YOUNG GU
事業者登録番号
853-44-00368
所在地
9F V24, 351 Gyeongin-ro, Michuhol-gu, Incheon, Republic of Korea
電話
+82-10-4404-1523
メール
whitecalvin@tastedev.net
個人情報保護責任者
CHOI YOUNG GU

© 2026 TASTEDEV製品情報は検証済みの開発ソースに基づいています。リリース・改善中

文字列アルゴリズム ドキュメント
文字列アルゴリズム
ConceptsHow It WorksImplementationComplexityPractice ProblemsReal-World Use
ディスカッション

文字列アルゴリズム ガイド · 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)
この章について質問がありますか?
前の章Practice 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件

人気のコメント順新しい順

ログイン · ログインするとコメントできます。