Category: Text function
This function returns the edit distance between two text strings calculated as the Damerau-Levenshtein distance.
This shows the number of text edits, such as character insertions or deletions, that is needed to produce text2 from text1. It is used to measure the degree of variance between two strings. The larger the edit distance, the more different the strings are.
Rating the similarity between words (fuzzy matching).
The detection of mistyped words.
Argument | Type | Description |
---|---|---|
text1 | Text | The "source" string value. |
text2 | Text | The "destination" string to transform text1 into . |
Return value type: Number
This function is case sensitive insofar as replacing a lower-case character with the upper-case version, or upper-case with the lower-case version, is considered an edit.
While numeric values can be entered for either argument, the function handles them as text strings for the calculation of the edit distance.
distance("cat", "cat") //Returns 0 (Strings are the same)
distance("cat", "cut") //Returns 1 (Change "a" to "u")
distance("cat", "dog") //Returns 3 (Change "c" to "d", "a" to "o", and "t" to "g")
distance("cat", "Scott") //Returns 3 (Delete "S" and one of the "t"s, and change "a" to "o")
distance("Mary","mary") //Returns 1 (Replace upper-case "M" with lower-case "m")
distance(100, 1) //Returns 2 (Remove both "0"s)
distance(100, "Bob") //Returns 3 (Replace "1" with "M", replace "0" with "a", and replace "0" with "r")