I would most likely create a function for something like this
Names Default To Here(1);
bigList = {"CD_CORN_1", "ICS_CORN_6", "IPEK21_S00R_P37_2", "CURR_S009_P37_2", "CD_CORN_2", "Ig_RF", "Cmax03_4C230RF", "NG"};
smallList1 = {"CD_CORN_", "CD_CORN_", "CD_CORN_"};
smallList2 = {"IDS_CORN_", "IPEK21_S00R_", "CURR_S009_"};
smallList3 = {"RF", "IPEK21_S00R_", "CURR_S009_", "NG"};
get_partial_matches = function({to_list, with_list}, {Default Local},
/*""" Get partial matches to_list using with_list
Args:
from_list (list(str)): list to compare to
to_list (list(str)): list to compare with
Returns:
list(str): List with partial matches in alphabetical order
"""*/
matches = Associative Array(); // associative array to avoid duplicates
For Each({to_item}, to_list,
For Each({with_item}, with_list,
If(Contains(to_item, with_item),
Insert Into(matches, to_item);
);
);
);
return(matches << get keys); // << get keys to get result in a list
);
list1 = get_partial_matches(bigList, smallList1);
list2 = get_partial_matches(bigList, smallList2);
list3 = get_partial_matches(bigList, smallList3);
show(list1, list2, list3);
other option would be something like this, but I would much rather use the earlier one
get_partial_matches2 = function({to_list, with_list}, {Default Local},
matches = Associative Array();
pattern = Concat Items(with_list, "|");
For Each({to_item}, to_list,
res = Regex(to_item, pattern);
If(!IsMissing(res),
Insert Into(matches, to_item);
);
);
return(matches << get keys);
);
list1 = get_partial_matches2(bigList, smallList1);
list2 = get_partial_matches2(bigList, smallList2);
list3 = get_partial_matches2(bigList, smallList3);
show(list1, list2, list3);
-Jarmo