In this example we will show how to match and split a string for a specified number of times using the split function in Python.
Source Code
import re
str1 = 'I love Python'
r = re.split('s', str1, 1)
print(r)
Output:
['I', 'love Python']
In this example we will show how to match and split a string for a specified number of times using the split function in Python.
import re
str1 = 'I love Python'
r = re.split('s', str1, 1)
print(r)
Output:
['I', 'love Python']