Advertisements
STRDIFF() Finds similarity between two strings (Levenshtein Distance) ------------------------------------------------------------------------------ Syntax STRDIFF(<cString1,<cString2>,[<nReplace>], [<nRemove>],[<nInsert>]) --> nDifferenceValue Arguments <cString1> Designates the first character string for the comparison. The replace, insert, and delete operations are carried out in this string. The maximum length for this string is 254 characters. <cString2> Designates the second character string for the comparison. <nReplace> Designates the number of valences (between 0 and 255) that are allocated for the replacement of a character. The default value is 3. <nRemove> Designates the number of valences (between 0 and 255) that are allocated for the removal of a character. The default value is 6. <nInsert> Designates the number of valences (between 0 and 255) that are allocated for the insertion of a character. The default value is 1. Returns STRDIFF() returns a value corresponding to the difference between the two character strings. The value can between 0 and 65535. Description Two different character strings can be made equal by deleting, inserting, or replacing characters within the first string. STRDIFF() attempts this in any combination until agreement has been reached. Since specific valences are allocated for each of the three individual operations, the end result is a total of valences from which the degree of similarity can be determined. With several paths to your end goal, the one to use is always the one that results in the smallest valence. In this way you can determine which stings of a group of character strings are the most similar. Notes . The maximum length of the combined string is determined as follows: 2 * (LEN(par1) + 1) * (LEN(par2) + 1) <= 65530 . If both strings are the same length, each can be a maximum of 180 bytes long. The result: 2 * 181 * 181 65522 . Implementing the SETATLIKE() function allows you to use wildcard characters within the search sequence. Examples . Here are some examples of STRDIFF(): ? STRDIFF("ABC", "ADC") // 3 - Replace 1 character ? STRDIFF("ABC", "AEC") // 3 - Replace 1 character ? STRDIFF("CBA", "ABC") // 6 - Replace 2 characters ? STRDIFF("ABC", "AXBC") // 1 - Insert 1 character ? STRDIFF("AXBC", "ABC") // 6 - Delete 1 character . Examples for the use of SETATLIKE() can be found under the corresponding function description.
See Also: SETATLIKE()
Advertisements