Real matching adds representation and streaming rules
Exact substring search is only one part of searching logs or DNA sequences. Define normalization, allowed symbols, case sensitivity, and whether a match may cross input-record boundaries.
For a pattern of length m split across streaming chunks, retain up to m-1 trailing characters for a naive window approach, or preserve KMP's matched-prefix state. Maintain a global offset so returned positions refer to the original stream rather than the latest chunk.
Pattern: ERROR
Chunk 1: "...ER"
Chunk 2: "ROR..."
Expected: one match spanning the boundary
DNA ambiguity codes may mean sets of possible bases, which changes equality semantics. Approximate matching with insertions or substitutions is not solved by ordinary exact KMP. Log processing also needs limits on retained data and a policy for malformed encoding.
Exercise
Implement a streaming exact matcher and feed the same text using every possible two-chunk split. Compare all results with a whole-string baseline.
Check: define whether line separators count as characters and whether matches can span lines. Avoid exposing matched private log content when reporting only counts or positions is sufficient.