- split() is a python regex function that returns a list where the string has been split at each match:
Syntax-
re.split(pattern,string,flag=0)
Example-
string is s="This-is-string"
re.split("-",s) will return ["This","is","string"]
program-
import re
print("Enter the string")
s=input()
#split according to the white space
x=re.split("s",s)
print(x)
#split with flag 1
x=re.split("s",s,1)
print(x)
#split with flag 2
x=re.split("s",s,2)
print(x)
Enter the string
This is a programming language in this universe
['This', 'is', 'a', 'programming', 'language', 'in', 'this', 'universe']
['This', 'is a programming language in this universe']
['This', 'is', 'a programming language in this universe']