Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Search := "lem"
- Data := ["Tuna",
- "Carrots",
- "Lemon",
- "How's it going?"
- ]
- Data_Score := []
- If !Search
- {
- MsgBox "Nothing Returns Nothing"
- Return
- }
- Loop DATA.Length
- {
- Score_Keeper := 0
- Search_Array := StrSplit(Search)
- Search_Length := StrLen(Search)
- Data_Array := StrSplit(Data[A_Index])
- Data_Length := StrLen(Data[A_Index])
- If (Data_Length = Search_Length)
- {
- Loop Search_Length
- {
- If (Data_Array[A_Index] != Search_Array[A_Index])
- Score_Keeper++
- }
- }
- Else If (Data_Length > Search_Length)
- {
- Loop Data_Length - Search_Length
- Score_Keeper++
- Loop Search_Length
- {
- If (Data_Array[A_Index] != Search_Array[A_Index])
- Score_Keeper++
- }
- Data_Score.Push Score_Keeper
- }
- Else If (Search_Length > Data_Length)
- {
- Loop Search_Length - Data_Length
- Score_Keeper++
- Loop Data_Length
- {
- If (Data_Array[A_Index] != Search_Array[A_Index])
- Score_Keeper++
- }
- Data_Score.Push Score_Keeper
- }
- }
- Loop Data_Score.Length
- {
- If Data_Score[A_Index] = Min(Data_Score*)
- Top_Match := Data[A_Index]
- }
- MsgBox Top_Match
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement