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.
Python3
# Python3 code to demonstrate working of# Split String on vowels# Using split() + regeximport re# initializing stringstest_str = 'GFGaBste4oCS'# printing original stringprint("The original string is : " + str(test_str))# splitting on vowels# constructing vowels list# and separating using | operatorres = re.split('a|e|i|o|u', test_str)# printing resultprint("The splitted string : " + str(res)) |
Output
The original string is : GFGaBste4oCS The splitted string : ['GFG', 'Bst', '4', 'CS']


.png)