Split a string of words by uppercase words
python, regex, string
Solution
>>> import itertools
>>> [
... ' '.join(items)
... for _, items in itertools.groupby('DEL MONTE Alfredo'.split(), str.isupper)
... ]
['DEL MONTE', 'Alfredo']
Problem
I have a set of names where the surname is in capital and first and middle names are normal, e.g. ``` OBAMA Barack DEL MONTE Alfredo ``` I want to split these in ``` "OBAMA", "Barack" "DEL MONTE", "Alfredo" ``` What is the pythonic way to achieve this?