target = 'a b c'
pattern = re.compile('\\s+')
subst = ''
print(list(vary(target, pattern, subst)))
target = 'abc123def'
pattern = re.compile('\\B(\\d+)\\B')
subst = '\\1 '
print(list(vary(target, pattern, subst)))
Combinatorial product of regex substitutions