Python – Split String on vowels
Given a String, perform split on vowels.
Input : test_str = ‘GFGaBst’
Output : [‘GFG’, ‘Bst’]
Explanation : a is vowel and split happens on that.
Input : test_str = ‘GFGaBstuforigeeks’
Output : [‘GFG’, ‘Bst’, ‘for’, ‘geeks’]
Explanation : a, u, i are vowels and split happens on that.
Method : Using regex() + split()
In this, we use regex split() which accepts multiple characters to perform split, passing list of vowels, performs split operation over string.
The original string is : GFGaBste4oCS The splitted string : ['GFG', 'Bst', '4', 'CS']
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course