Check List for Items in Another List?

So I have two lists.

For the sake of example, one of them is {“1”, “2”}, and the other is {“12”, “34”}

I want to have a loop, and check if each item of the second list contains ANY item of the first list.

So:


repeat with myCount from 1 to (count items of myFirstList)
if item myCount of myFirstList contains any item of mySecondList then return true
end repeat

However, this doesn’t work. Is there a simple, easy way to do this? Both of the lists contain only strings.

I know I can do a bunch of loops and make it all complicated and slow, but I’m almost sure there must be a better way to approach this.

Thanks.

-SuperScripter

Here, it is not “contains any item of” but “is in”:

repeat with myCount from 1 to (count items of myFirstList)
	if item myCount of myFirstList is in mySecondList then return true
end repeat

Alright, sorry, turns out it’s a bit more complicated, and I’m stuck again. :confused:

I need to check a string to see if it contains any item in a list.

Once again, I feel really close to the answer, and that it should be obvious, but I keep missing.

-SuperScripter

Or you can do:

repeat with i in myFirstList
	if i is in mySecondList then return true
end repeat

Alright, the second one, modified, works. Thanks!

If anyone cares:


repeat with i in myList
   if myString contains i then return true
end repeat

-SuperScripter

Or that… :stuck_out_tongue: