Skip to main content

Python RegEx split() Functions

This function splits the string at every occurrence of the sub-string and returns a list of strings which have been split.

Split string by the occurrences of a character or a pattern, upon finding that pattern, the remaining characters from the string are returned as part of the resulting list. 


import re
re.split(pattern, string, maxsplit=0, flags=0)


import re
str1 = "Welcome to Python Programming"
res = re.split("\s", str1)

Output: ['Welcome', 'to', 'Python', 'Programming']

Submitted by devanshi.srivastava on July 23, 2021

Devanshi, is working as a Data Scientist with iVagus. She has expertise in Python, NumPy, Pandas and other data science technologies.


At ProgramsBuzz, you can learn, share and grow with millions of techie around the world from different domain like Data Science, Software Development, QA and Digital Marketing. You can ask doubt and get the answer for your queries from our experts.