w3resource logo
Python Exercises

Python: Split a string at uppercase letters

Python Regular Expression: Exercise-43 with Solution

Write a Python program to split a string at uppercase letters.

Sample Solution:-

Python Code:

import re
text = "PythonTutorialAndExercises"
print(re.findall('[A-Z][^A-Z]*', text))

Sample Output:

['Python', 'Tutorial', 'And', 'Exercises']

Python Code Editor:

import re
text = "PythonTutorialAndExercises"
print(re.findall('[A-Z][^A-Z]*', text))

Improve this sample solution and post your code through Disqus