What is the pythonic way to split a string before the occurrences of a given set of characters?
For example, I want to split
'TheLongAndWindingRoad'
at any occurrence of an uppercase letter (possibly except the first), and obtain
['The', 'Long', 'And', 'Winding', 'Road'].
Edit: It should also split single occurrences, i.e.
from 'ABC' I’d like to obtain
['A', 'B', 'C'].
Unfortunately it’s not possible to split on a zero-width match in Python. But you can use
re.findallinstead: