mikamol
(Mikael Möller)
1
Hi fellas!
Is there any neat way to check if a string contains all elements in a array of strings, and in the correct order?
Ex:
string_test = “This is a string example”
array_test = {“This”, “a”, “example”}
array_test2 = {“This”, “example”, “a”}
array_test3 = {“This”, “example”. “intager”}
Only “array_test” would be correct.
// 
1 Like
Yes we have of course
If the string is stored in a variable named str_input
Then use a assign activity like this
arr_input = Split(Str_input,” “)
Where arr_input is a variable of type array of string
Now use a IF condition like this
arr_input.Equals(arr_test)
If true it goes to THEN part or goes to ELSE part
Cheers @mikamol
1 Like
ppr
(Peter Preuss)
3
@mikamol
Lets assume we can split the string by space for the compair
using within an assign:
array_test2.SequenceEqual(string_test .Split(" "c))
will return true or false
1 Like
mikamol
(Mikael Möller)
4
Well, the Input string might contain more words than the Array we are testing against, so that wont work 
ppr
(Peter Preuss)
5
@mikamol
in case you will check some statements from above kindly note:
string_test = “This is a string example” vs. array_test = {“This”, “a”, “example”}
is, string is missing and will evaluate to false as well due:
if a string contains all elements in a array of strings, and in the correct order?
Yes buddy
That is what we are trying to validate right
So if the string has more words than in the array then obviously it will not match and goes for ELSE part of IF condition
Cheers @mikamol
StringCompare.xaml (10.5 KB)
I have tested with these inputs,
array_test = {“This”, “a”, “example”}
array_test2 = {“This”, “example”, “a”}
array_test3 = {“This”, “example”. “intager”}
Kindly check…! @mikamol
Thanks!