Why exact string matching still matters

There is a tendency in any technical field to assume that the newest method is the best one. In plagiarism detection – and the broader family of problems concerned with finding copied text within and across very large document collections – the discourse of the past decade has been dominated by semantic embeddings, transformer-based paraphrase detection, and large-language-model-aware classifiers. Each of these has earned its place. None of them has displaced the technique that actually does most of the work in production systems.

That technique is exact string matching: the identification of contiguous, character-for-character or token-for-token overlaps between a candidate document and a reference corpus. It is the oldest detection family, the simplest to implement, and the easiest to reason about. It is also the one that, for a substantial proportion of real-world copying, simply works – fast, cheaply, and with a clarity of evidence that no semantic system can match. This article makes the case for taking exact matching seriously: as a method that excels at a specific class of problems, as the substrate on which more sophisticated systems are built, and as the residual baseline that every responsible detection pipeline still depends on.

What exact string matching actually means

Exact string matching, in the plagiarism context, is the search for runs of identical text – defined at the level of characters, words, or normalised tokens – that appear in both a query document and a reference document. The textbook formulation is given in any introduction to string algorithms: given a pattern of length m and a text of length n, find every position in the text where a substring of length m equals the pattern exactly.

Three classical algorithms dominate the literature. The Knuth–Morris–Pratt algorithm preprocesses the pattern to skip redundant comparisons, achieving linear worst-case time in the length of the inputs. The Boyer–Moore algorithm scans the pattern right-to-left and uses bad-character and good-suffix heuristics to skip ahead in the text, producing sublinear behaviour on typical inputs. The Rabin–Karp algorithm, introduced by Karp and Rabin in 1987, takes a different approach: it computes a rolling hash of each m-character window of the text and compares it against the hash of the pattern, falling back to a full character comparison only when the hashes match.

For plagiarism detection specifically, Rabin–Karp is the algorithm that matters, and the reason is given explicitly in the original paper’s discussion of applications. As the canonical reference notes:

A practical application of the algorithm is detecting plagiarism. Given source material, the algorithm can rapidly search through a paper for instances of sentences from the source material, ignoring details such as case and punctuation. Because of the abundance of the sought strings, single-string searching algorithms are impractical.

The crucial phrase is the abundance of the sought strings. The plagiarism problem is not the textbook problem of finding one pattern in one text. It is the problem of finding any of millions of patterns – every sentence, or near-sentence-length substring, of every document in a reference corpus – in a query document. Knuth–Morris–Pratt and Boyer–Moore are faster than Rabin–Karp for a single pattern, but Rabin–Karp generalises trivially to multi-pattern search: hash all the patterns into a hash set, then perform the rolling-hash scan once, looking up each window’s hash in the set in expected constant time. The total cost scales with the size of the text plus the size of the pattern set, rather than with their product. At corpus scale, this is the difference between feasible and infeasible.

The technique generalises further still through document fingerprinting, in which both the query and the reference corpus are reduced to compact sets of hash values representing their constituent k-grams (or, in the language of Broder’s 1997 paper on syntactic clustering, their shingles). Two documents that share a substantial fraction of their fingerprints almost certainly share substantial verbatim text. The resemblance between two documents can then be defined as the Jaccard coefficient of their shingle sets – the size of the intersection divided by the size of the union:

r(A, B) = |S(A) ∩ S(B)| ÷ |S(A) ∪ S(B)|

Once both documents are represented as fingerprint sets, the comparison becomes a set-intersection problem rather than a sequence-comparison problem – amenable to inverted indexes, MinHash sketches, locality-sensitive hashing, and all the other apparatus that allows large-scale similarity search to run in time sublinear in the size of the corpus.

This is the family of techniques I am calling exact string matching. It includes raw character matching, token-level matching after normalisation, k-gram fingerprinting, shingling, winnowing, and the suffix-tree and suffix-array methods used in systems like MatchDetectReveal and MOSS. What unites them is that the unit of comparison is literal: two pieces of text either match exactly at the relevant level of representation, or they do not. There is no probability of semantic equivalence to estimate, no embedding distance to threshold. The match is binary, and the evidence is the matched substring itself.

Where it works brilliantly

To understand why exact matching has not been displaced by more sophisticated methods, it helps to look at the contexts in which it performs at the very top of its game.

Verbatim copying at scale

The most obvious case is the one the technique was designed for. When a writer has copied a passage of source text without alteration – the clone in the Plagiarism Spectrum’s terminology – exact matching detects it with mathematical certainty. The winnowing algorithm developed by Schleimer, Wilkerson and Aiken at Stanford guarantees that any contiguous shared run above a configurable threshold length will produce at least one matching fingerprint, irrespective of where in either document it appears. With the typical parameters used in MOSS, the threshold is around eight tokens — roughly a single moderately long sentence.

The 2003 SIGMOD paper reporting on MOSS, the most widely deployed code-similarity system in academia, makes the practical implications concrete. The system has been running continuously since 1994, fingerprints submitted programs after a language-aware tokenisation step, and uses inverted indexes mapping fingerprints to source locations to identify candidate matches. When a pair of submissions shares a large number of fingerprints, the system surfaces them for human review, with the matched regions highlighted in both files. The Stanford team’s own description of the system is admirably restrained:

Moss is not a system for completely automatically detecting plagiarism. Plagiarism is a statement that someone copied code deliberately without attribution, and while Moss automatically detects program similarity, it has no way of knowing why codes are similar. It is still up to a human to go and look at the parts of the code that Moss highlights and make a decision.

This restraint is the right one, and it generalises beyond code. Exact matching does not prove plagiarism. It identifies, with essentially perfect recall on its target class, candidate regions for human judgement. That is a different and more useful claim than the one usually made on behalf of detection software.

Near-duplicate detection on the web

The single largest application of exact-match-based techniques is not in academic plagiarism detection at all. It is in the deduplication pipelines that every major search engine runs to keep its index clean. Andrei Broder’s work at AltaVista in the mid-1990s, formalised in Syntactic Clustering of the Web and the closely related On the Resemblance and Containment of Documents, is the foundational work here.

Broder’s insight was that the resemblance between two documents could be estimated to arbitrary precision by comparing fixed-size random samples of their shingle sets, drawn using minimum-hash sampling. The 1996 AltaVista experiments processed 30 million HTML and text documents (150 GB), using 10-word shingles fingerprinted to 40 bits, and identified 3.6 million clusters of near-duplicate pages and 2.1 million clusters of identical pages. The total sample size required was less than 50 bytes per document.

Three observations are worth making about this result. First, it scales: the comparison is effectively constant-time per document pair, because the sketches are fixed-size. Second, it is purely an exact-matching technique – every shingle is a literal contiguous sequence of words, and every match is a literal hash equality. The “near” in “near-duplicate” refers to the aggregate relationship between two documents (most of their shingles match), not to any softening of the per-shingle comparison itself. Third, it works. The method has been the basis of duplicate detection at major search engines for nearly three decades, supplemented but not replaced by SimHash, MinHashLSH and other variants that are themselves built on the same foundation.

Code plagiarism

Exact matching has a particularly strong claim in source-code plagiarism, where the structural similarity that betrays copying is preserved through normalisation in a way that natural-language semantic equivalence is not. The MOSS approach – tokenise the program, replacing variable and function names with generic tokens, then apply winnowing to the token stream – is essentially exact matching after a semantically motivated normalisation step. The result is a system that, as a recent technical analysis summarises it, is “resilient to renaming variables, changing comment text, and reformatting whitespace” while still operating on literal token-sequence overlap.

Suffix-tree and suffix-array methods carry the same logic further. The classical paper by Mozgovoy, Fredriksson, White, Joy and Sutinen describes a code-plagiarism system that tokenises every file in the collection, builds a suffix array over the concatenated token stream, and then locates all maximal common substrings between any pair of files in near-logarithmic time per query. For the all-pairs problem on a collection of files totalling many millions of tokens, the system is substantially faster than pairwise tools like JPlag. As Gipp summarises the underlying trade-off in his comparative analysis of plagiarism detection methods:

The strength of substring matching methods is their perfect detection accuracy with regard to literal text overlaps. Their major drawbacks are the relative difficulty of detecting disguised plagiarisms as well as the required computational effort.

This is the trade-off in microcosm. Where the copying is literal, the detection is essentially perfect. Where the copying is disguised – paraphrased, reordered, semantically rephrased – exact matching alone is insufficient, and other methods must take over. The error is to imagine that the second case has supplanted the first. It has not.

Why it remains the backbone

Even in systems designed primarily to catch paraphrase or AI-generated text, exact string matching persists as the foundational layer. There are four reasons for this, and they apply broadly across the field.

Speed and scalability

Exact-match algorithms run in time linear, or near-linear, in the size of the input. None of the available semantic methods improves on this. Sentence-BERT comparisons, even with optimised approximate-nearest-neighbour indexes, are at least an order of magnitude slower per comparison and require substantially more memory for the embedding index. At the scale of a commercial detection corpus – Turnitin’s, for instance, contains over a billion student papers and tens of trillions of indexed web pages – the cost difference is decisive. An exact-match pass over the whole corpus is feasible. A semantic pass is not, except as a second-stage filter on candidates already surfaced by an exact-match first stage.

Provability of the evidence

When an exact-match system reports that a candidate document shares a 47-word run with a source document, the evidence is the shared run. There is no inference to dispute, no embedding distance to debate, no model to interrogate for bias. Either the words are the same in the same order or they are not. This evidentiary clarity matters enormously when detection feeds into adjudication processes – academic integrity panels, editorial corrections, copyright disputes – where the standard of proof is high and the decision is consequential. A semantic system that reports “these passages are 0.91 cosine-similar in embedding space” is making a useful claim, but it is not a claim that can stand on its own in front of a tribunal. A 47-word literal overlap can.

Predictable failure modes

Exact matching fails predictably. It catches verbatim copying. It catches verbatim copying with minor reformatting (after normalisation). It catches mosaic borrowing where any individual fragment exceeds the matching threshold. It does not catch genuine paraphrase, true mosaic at the sub-threshold level, translation, or AI-rephrased text. Every operator of an exact-match system knows where its blind spots are, and the false-negative behaviour is well-characterised. This is, oddly, an advantage. A system whose failure modes are predictable can be augmented with complementary systems – a paraphrase detector here, a stylometric inconsistency check there – each compensating for known gaps. A system whose failure modes are themselves probabilistic and corpus-dependent (which is the situation with most learned systems) is much harder to compose into a robust pipeline.

The first-pass filter pattern

The decisive operational fact is that exact matching is almost always faster than the methods that would succeed it. This makes it ideal as a first-pass filter: run the cheap, high-recall, perfect-precision-on-its-target-class technique first; surface its hits directly; pass the rest of the document, plus any low-confidence candidate matches, to slower and more sophisticated downstream systems. This is the architecture of essentially every production detection pipeline today. Turnitin’s similarity report combines verbatim fingerprint matches with paraphrase-aware secondary checks. Google’s deduplication pipeline combines shingle-based clustering with a battery of more semantic relevance signals. Codequiry, Dolos, and the other modern code-similarity tools all use winnowing or suffix-array exact matching as the entry point to their pipelines.

The pattern is so consistent that it amounts to a design principle: exact matching is what you do first, because anything you can find with it, you should. The expensive methods are reserved for what literal overlap leaves behind.

What it cannot do

Exact matching has well-understood limitations, and a fair account must state them directly.

It cannot detect paraphrase. Two passages that express the same proposition in entirely different words will share no fingerprints, and an exact-match system will flag nothing. The Howard and Citation Project research on patchwriting, discussed in detail elsewhere in this series, identifies exactly this gap: a student who substitutes a synonym every fourth or fifth word will defeat n-gram fingerprinting at typical configurations, even though the underlying borrowing is substantial.

It cannot detect translation. A passage translated from English to Spanish and back will share essentially no exact tokens with the original, even though the semantic relationship is undeniable. Cross-language plagiarism detection is necessarily a different problem, requiring either translation-aware retrieval or shared multilingual embedding spaces.

It cannot detect idea theft. The unattributed appropriation of an argument, an analytical framework, or an empirical result – without the appropriation of any particular wording – is invisible to any literal-overlap method. This is one of the most serious forms of misappropriation in academic and journalistic writing, and it is one for which automated detection has historically been weakest.

It cannot, on its own, distinguish copying from coincidence. Common idioms, technical formulations whose phrasing is essentially fixed by convention, quotations from a shared source, instructor-supplied code in a programming assignment – all of these produce literal overlaps that are not plagiarism. Every well-engineered exact-match system therefore includes mechanisms for excluding such legitimate matches: MOSS’s option to ignore passages appearing in more than a configurable number of submissions; base-file exclusion lists; corpus-wide frequency filtering of common shingles. These mechanisms are not optional. They are what distinguishes a usable exact-match system from one that drowns its operators in false positives.

It cannot, finally, replace human judgement. The MOSS team’s framing of their system as a tool that “saves teachers and teaching staff a lot of time by pointing out the parts of programs that are worth a more detailed examination” is the right framing for the entire family. Exact matching surfaces candidates. Humans adjudicate.

What this means for the field

Two practical conclusions follow.

The first is for builders of detection systems. The temptation to skip directly to semantic methods, on the assumption that the exact-match layer is solved and uninteresting, should be resisted. The exact-match layer is where most of the actual detection happens. Investments in better tokenisation, smarter normalisation, broader corpus coverage, faster fingerprint indexes, and more sophisticated frequency-based filtering produce more measurable improvements in real-world detection quality than incremental gains on paraphrase benchmarks. The state of the art in plagiarism detection is, in significant part, the state of the art in scalable exact matching – and that is a field in which the engineering details still matter enormously.

The second is for users of detection systems – instructors, editors, integrity officers, anyone who reads a similarity report and has to decide what to do with it. The literal-overlap matches are the matches that mean something. They are the ones the system can be trusted on, the ones that can be reproduced and verified, and the ones that justify whatever process follows. The lower-confidence semantic flags are useful as prompts for a closer look, but they are not, on their own, the basis for a finding. Knowing the difference – and treating exact matches and semantic matches as the categorically different kinds of evidence they are – is the most important skill in interpreting these reports correctly.

Exact string matching has been, for thirty years, the boring workhorse of textual duplicate detection. It is not glamorous. It does not feature in conference keynotes about the future of natural language processing. It does, however, do the work. The newer methods that get the attention are extensions, complements and refinements of it – almost never replacements. That is a reasonable summary of where the field is, and where, for the foreseeable future, it is likely to remain.

Exact string matching is the workhorse of plagiarism detection – fast, provable, and excellent at catching verbatim copying. But it is, deliberately, only the first layer. Real-world plagiarism today involves paraphrase, mosaic stitching, translation, and AI-generated rewrites that literal overlap alone will miss. Viper Plagiarism and AI Checker does both. The plagiarism engine combines fingerprint-based exact matching with paraphrase-aware and cross-language detection, scanning against more than 60 trillion web pages, 16,000+ open-access journals and over a million internal documents. Coverage extends to 100+ languages, with references and quotations excludable from the analysis. The integrated AI detector runs in the same scan, with 99.12% benchmark accuracy across Claude, GPT-4, Gemini and other major models. Everything exact matching catches, plus everything it doesn’t – in a single report. Try Viper now.

References and further reading:

  • Aiken, A. (1994–) Moss: A system for detecting software similarity. Stanford University. Available at: https://theory.stanford.edu/~aiken/moss/) (Accessed: 13 May 2026).
  • Broder, A. Z. (1997) ‘On the resemblance and containment of documents’, in Compression and Complexity of Sequences 1997. IEEE Computer Society, pp. 21–29.
  • Broder, A. Z. (2000) ‘Identifying and filtering near-duplicate documents’, in Giancarlo, R. and Sankoff, D. (eds.) Combinatorial Pattern Matching, CPM 2000, Lecture Notes in Computer Science, vol. 1848. Berlin: Springer, pp. 1–10.
  • Broder, A. Z., Glassman, S. C., Manasse, M. S. and Zweig, G. (1997) ‘Syntactic clustering of the web’, in Sixth International World Wide Web Conference.
  • Codequiry (2025) What code similarity metrics actually measure in student work. Available at: https://codequiry.com/blog/what-code-similarity-metrics-actually-measure-in-student-work (Accessed: 13 May 2026).
  • Gipp, B. (2014) Citation-based plagiarism detection. Wiesbaden: Springer Vieweg.
  • Karp, R. M. and Rabin, M. O. (1987) ‘Efficient randomized pattern-matching algorithms’, IBM Journal of Research and Development, 31(2), pp. 249–260.
  • Manning, C. D., Raghavan, P. and Schütze, H. (2008) Introduction to information retrieval. Cambridge: Cambridge University Press, ch. 19.6 (‘Near-duplicates and shingling’).
  • Monostori, K., Zaslavsky, A. and Schmidt, H. (2000) ‘MatchDetectReveal: Finding overlapping and similar digital documents’, in Proceedings of the 2000 Information Resources Management Association International Conference, pp. 955–957.
  • Mozgovoy, M., Fredriksson, K., White, D., Joy, M. and Sutinen, E. (2005) ‘Fast plagiarism detection system’, in String Processing and Information Retrieval, SPIRE 2005, Lecture Notes in Computer Science, vol. 3772. Berlin: Springer, pp. 267–270.
  • Schleimer, S., Wilkerson, D. S. and Aiken, A. (2003) ‘Winnowing: Local algorithms for document fingerprinting’, in Proceedings of the 2003 ACM SIGMOD International Conference on Management of Data, pp. 76–85.