String Operations

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > String commands > !STR.- String Command > Instring - Find Commands >

String Operations

STR.FindBestMatch

Previous Top Next


MiniRobotLanguage (MRL)

 

STR.FindBestMatch

Find the best match for a given string in a list of strings using Levenshtein distance, return a number.

 

 

Intention

 

The STR.FindBestMatch Command is used to find the closest matching string in a list of strings to a given string.

The Command uses the Levenshtein distance algorithm for string comparison.

 

The result will be the best matching element and the element number corresponding to the best match in the list or -1 if an error occurs on TOS.

The result will be placed in an optional variable P3 or on TOS if the variable is omitted.

 

 

 

 

Syntax

 

 

STR.FindBestMatch|P1|P2[|P3]

STR.FBM|P1|P2[|P3]

 

 

 

Parameter Explanation

 

•P1 - (List, Text) Variable containing a comma or semicolon-separated list of strings. The strings may not contain comma or ; inside.

•P2 - (Target, Text) Variable containing the string to compare against the list.

•P3 - (Output, Numeric) Optional variable to store the result. If omitted, the result is placed on TOS.

 

 

 

 

Example

 

VAR.$$LIS=1. apple,2. orange,3. banana

VAR.$$TAR="orenge"

STR.FindBestMatch|$$LIS|$$TAR|$$RES

' Element in the Result Variable

DBP.Best Match: $$RES

' Element Number on TOS

DBP.$tos$

' Result is 2. orange

' and you have 2 on TOS.

ENR.

 

 

Remarks

 

-

 

 

Limitations:

 

-

 

 

See also:

 

•     1.5.2 Working with Text-Strings

•     VAR. - Variable Set Value/Clear

•     VAS. - Variable with String

•     RPL. - RePLace in String

•     IVS. / NVS. - If-Variable-String

•     GSS. - GetSplitString

•     GFS. - Get-Filtered-String

•     GES. - Get-Extracted-String

•     SBD. - String between Delimiter

•     SBM. - String between Delimiter-Multiple

•     FEM. - For Each Member

•     LEN. - Length-of-String