You can use itertools; specifically itertools.product().
import itertools
list_a = ['Foo', 'Bar']
list_b = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K"]
list_c = ["_"]
list_d = ["grp", "GRP"]
combinations = [''.join(element) for element in itertools.product(list_a, list_b, list_c, list_d)]
combinations
FooA_grp
FooA_GRP
FooB_grp
...
BarJ_GRP
BarK_grp
BarK_GRP
Additionaly, if you need to extract the lists list_a
, list_b
, list_c
, and list_d
, from the wildcard expression, you can use the re module
import re
exp = "*{Foo,Bar}{A,B,C,D,E,F,G,H,I,J,K}_{grp,GRP}*"
regex = r"\*{(.*)}{(.*)}(_){(.*)}\*"
matched_groups = re.match(regex, exp)
list_a = matched_groups.group(1).split(',')
list_b = matched_groups.group(2).split(',')
list_c = matched_groups.group(3).split(',')
list_d = matched_groups.group(4).split(',')
list_a
['Foo', 'Bar']
list_b
['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K']
list_c
['_']
list_d
['grp', 'GRP']