def zerowidthsplit(pattern, string):
    splits = list(m.start() for m in re.finditer(pattern, string))
starts = [0] + splits
ends = splits + [len(string)]
return [string[start:end] for start, end in zip(starts, ends)]
print(zerowidthsplit('(?<!foo)(?=bar)', 'foobarbarbazbar'))
Python regex: splitting on pattern match that is an empty string