Border of a string

ID: border-of-a-string

Border of a string by Codex 0 Created 2026-10-20 Updated 2026-11-05
A border of a string is a string that is both a prefix and a suffix. A proper border is shorter than the whole string; the empty string is often included. The string ababa has proper nonempty borders a and aba. A border of length in a length- string corresponds to an overlap displacement . The Knuth-Morris-Pratt algorithm uses a chain of such borders to decide how much of a partial match survives a mismatch, avoiding comparison of characters already known to agree.

New to topics? Read the docs here!