LevenshteinDistance

LevenshteinDistance(string1, string2, ignoreCase): int

Calculates the Levenshtein distance between two strings, which is the minimum number of single-character edits (insertions, deletions, substitutions) needed to transform one string into another.

Added in version 6.0

Table 1. Parameters

string1

String

First string to compare

string2

String

Second string to compare

ignoreCase

Boolean

Optional. If TRUE, performs case-insensitive comparison. Defaults to FALSE

Return

Integer representing the edit distance between the two strings.

// Calculate distance between two strings
distance = LevenshteinDistance("kitten", "sitting");
println(distance);  // prints 3

// Case-insensitive comparison
distance = LevenshteinDistance("Hello", "hello", true);
println(distance);  // prints 0