2 replaced http://mathematica.stackexchange.com/ with https://mathematica.stackexchange.com/ edited Apr 13 '17 at 12:55 Here's a direct list-manipulation approach using a variation of Heike's answeranswer for combining subsets with similar terms: Cases[list1, {___, Alternatives @@ #, ___}, 2] & /@ list2 //. x_ :> Union @@@ Gather[x, Intersection@## =!= {} &] (* {{{1, 2}, {31, 32}, {45, 46}}, {{5, 6}, {27, 28}}, {{7, 8}, {41, 42}}, {{21, 22}, {25, 26}, {29, 30}}, {{33, 34}, {35, 36}, {37, 38}}, {{47, 48}, {49, 50}}} *)  Here's a direct list-manipulation approach using a variation of Heike's answer for combining subsets with similar terms: Cases[list1, {___, Alternatives @@ #, ___}, 2] & /@ list2 //. x_ :> Union @@@ Gather[x, Intersection@## =!= {} &] (* {{{1, 2}, {31, 32}, {45, 46}}, {{5, 6}, {27, 28}}, {{7, 8}, {41, 42}}, {{21, 22}, {25, 26}, {29, 30}}, {{33, 34}, {35, 36}, {37, 38}}, {{47, 48}, {49, 50}}} *)  Here's a direct list-manipulation approach using a variation of Heike's answer for combining subsets with similar terms: Cases[list1, {___, Alternatives @@ #, ___}, 2] & /@ list2 //. x_ :> Union @@@ Gather[x, Intersection@## =!= {} &] (* {{{1, 2}, {31, 32}, {45, 46}}, {{5, 6}, {27, 28}}, {{7, 8}, {41, 42}}, {{21, 22}, {25, 26}, {29, 30}}, {{33, 34}, {35, 36}, {37, 38}}, {{47, 48}, {49, 50}}} *)  1 answered Mar 5 '14 at 2:22 rm -rf♦ 81.8k1919 gold badges256256 silver badges414414 bronze badges Here's a direct list-manipulation approach using a variation of Heike's answer for combining subsets with similar terms: Cases[list1, {___, Alternatives @@ #, ___}, 2] & /@ list2 //. x_ :> Union @@@ Gather[x, Intersection@## =!= {} &] (* {{{1, 2}, {31, 32}, {45, 46}}, {{5, 6}, {27, 28}}, {{7, 8}, {41, 42}}, {{21, 22}, {25, 26}, {29, 30}}, {{33, 34}, {35, 36}, {37, 38}}, {{47, 48}, {49, 50}}} *)