It seems to me that the OP is not really about computing the difference (or intersection) between two arrays, but more about how to do the match when one of the arrays may have a generic "*" character in some of its elements to represent some other characters. So probably more a regex question. I won't go further into that, since the original poster has apparently found a solution.