levenshtein

Computes the Levenshtein distance between this string and other.

The Levenshtein distance is the minimum number of single-character edits (insertions, deletions, or substitutions) required to transform one string into the other. This implementation uses the classic Wagner-Fischer dynamic-programming algorithm with O(m * n) time and space complexity, where m and n are the lengths of the two strings.

Used internally by closestMatch to power "did you mean ...?" suggestions in ConfigError.UnknownKey.

Examples:

"kitten".levenshtein("sitting")  // 3
"host".levenshtein("hots") // 2
"abc".levenshtein("abc") // 0
"".levenshtein("hello") // 5

Return

The edit distance as a non-negative integer. Returns 0 when the strings are identical.

Since

1.0

Parameters

other

The target string to compare against.

See also