levenshteinDistance
Levenshtein edit distance between two strings — the minimum number of single-character
insertions, deletions, or substitutions needed to turn a into b.
Available since v3.1.1
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
a | string | The first string |
b | string | The second string |
caseSensitive | boolean | Whether the comparison is case-sensitive. Defaults to `true`. |
Returns
Section titled “Returns”number — The edit distance; 0 when a and b are equal (after case-folding when
caseSensitive is false)
Examples
Section titled “Examples”Classic edit-distance example
Section titled “Classic edit-distance example”“kitten” becomes “sitting” with 3 single-character edits.
Case-insensitive comparison
Section titled “Case-insensitive comparison”Pass false to ignore letter case when comparing.
