prefixes = ['over', 'under', 're', 'un', 'co']

def test(string, prefixes, existing=None):
    prefixes.sort(key=lambda s: len(s))
prefixes.reverse()
if existing is None:
    existing = []
for prefix in prefixes:
    if string.startswith(prefix):
        existing.append(prefix)
return test(string[len(prefix):], prefixes, existing)
existing.append(string)
return existing
Recursively split strings that contains a defined set of prefixes - Python