Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Python – Split String on vowels

  • Last Updated : 01 Jun, 2021

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

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!