STD.Str.EditDistance( string1, string2, radius )
STD.Uni.EditDistance( string1, string2, locale, radius )
string1 | The first of a pair of strings to compare. |
string2 | The second of a pair of strings to compare. |
locale | A null-terminated string containing the language and country code to use to determine correct sort order and other operations. |
radius | Optional. The maximum acceptable edit distance, or 0 for no limit. Defaults to 0. |
Return: | EditDistance returns an UNSIGNED4 value. |
The EditDistance function returns a standard Levenshtein distance algorithm score for the edit distance between string1 and string2. This score reflects the minimum number of operations needed to transform string1 into string2.
If the edit distance is larger than the radius it will return an arbitrary value > radius, but it may not be accurate. This allows the function to terminate faster if the strings are significantly different.
Example:
STD.Str.EditDistance('CAT','CAT'); //returns 0 STD.Str.EditDistance('CAT','BAT'); //returns 1 STD.Str.EditDistance('BAT','BAIT'); //returns 1 STD.Str.EditDistance('CAT','BAIT'); //returns 2 STD.Str.EditDistance('CARTMAN','BATMAN'); //returns 2 STD.Str.EditDistance('CARTMAN','BATMAN',1); //returns arbitrary number > 1