I urgently need some help, in finding matching words between "n" number of variables. I am creating a Gui, which will give me multiple variable containing text.
The first and the last variable is known, but the number of variables between the 1st and the last variable is not constant. It can vary based on the user choice.
I want a script, that must identify the numbers of variables between the 1st and the last variable and then find the matching words between all the variables.
I have a script that is able to find the matching words between 4 variables. But The user can input any number of variables between the Initial and Final variable.
Example Script for finding matching words -
Code: Select all
initial = (A1 - Superior lateral to medial MEGA ,[P-10])
var1 = (A2 - SUPERIOR MEGA [P-10])
var2 = (A3 - SUPERIOR MEGA [P-10])
final= (A4 - SUPERIOR MEGA [P-10])
Variable1 := initial
Variable2 := var1
Variable3 := var2
Variable4 := final
send, Initial - %Variable1% `n
send, Var1 - %Variable2% `n
send, Var2 - %Variable3% `n
send, Final - %Variable4% `n
send, `n
Loop, Parse, Variable1, % A_Space,",-()[];"
{
Word1 := A_LoopField
Loop, Parse, Variable2, % A_Space
{
Word2 := A_LoopField
Loop, Parse, Variable3, % A_Space
{
Word3 := A_LoopField
Loop, Parse, Variable4, % A_Space
{
Word4 := A_LoopField
If (Word1 = Word2) && (Word1 = Word3) && (Word1 = Word4) {
Output .= Word1 " "
Variable1 := RegExReplace(Variable1, "\b" Word1 "\b")
Variable2 := RegExReplace(Variable2, "\b" Word2 "\b")
Variable3 := RegExReplace(Variable3, "\b" Word3 "\b")
Variable4 := RegExReplace(Variable4, "\b" Word4 "\b")
}
}
}
}
}
winactivate,Untitled - Notepad
send, Common Word - %Output% `n
send,`n
Output := RegExReplace(Output, "^\s+|\s+$", "")
Variable1 := RegExReplace(Variable1, "\,", "")
Variable1 := RegExReplace(RegExReplace(Variable1, "\. {1," X "}(?! )", ". "), "[^ \.]\K {1," X "}(?! )", " ")
Variable2 := RegExReplace(RegExReplace(Variable2, "\. {1," X "}(?! )", ". "), "[^ \.]\K {1," X "}(?! )", " ")
Variable3 := RegExReplace(RegExReplace(Variable3, "\. {1," X "}(?! )", ". "), "[^ \.]\K {1," X "}(?! )", " ")
Variable4 := RegExReplace(RegExReplace(Variable4, "\. {1," X "}(?! )", ". "), "[^ \.]\K {1," X "}(?! )", " ")
send, Edited Initial - %Variable1% `n
send, Edited var1 - %Variable2% `n
send, Edited var2 - %Variable3% `n
send, Edited Final - %Variable4% `n