w3resource

Python: Split a string at uppercase letters

Python Regular Expression: Exercise-43 with Solution

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

Sample Solution:

Python Code:

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

Sample Output:

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

Pictorial Presentation:

Python: Regular Expression - Split a string at uppercase letters.

Flowchart:

Flowchart: Regular Expression - Split a string at uppercase letters.

Python Code Editor:

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous: Write a Python program to find urls in a string.
Next: Write a Python program to do a case-insensitive string replacement.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://w3resource.com/python-exercises/re/python-re-exercise-43.php