How to do CamelCase split in python
What I was trying to achieve, was something like this: >>> camel_case_split("CamelCaseXYZ") ['Camel', 'Case', 'XYZ'] >>> camel_case_split("XYZCamelCase") ['XYZ', 'Camel', 'Case'] So I searched and found this perfect regular expression : (?<=[a-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z]) As the next logical step I tried: >>> re.split("(?<=[a-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])", "CamelCaseXYZ") ['CamelCaseXYZ'] Why does this not work, and how do I achieve the result from the linked question in python? Edit: Solution summary I tested all provided solutions with a few test cases: string: ''