>>> re.split(r'W+', 'Words, words, words.')
['Words', 'words', 'words', '']
>>> re.split(r'(W+)', 'Words, words, words.')
['Words', ', ', 'words', ', ', 'words', '.', '']
>>> re.split(r'W+', 'Words, words, words.', 1)
['Words', 'words, words.']
>>> re.split('[a-f]+', '0a3B9', flags=re.IGNORECASE)
['0', '3', '9']
s_comma = 'one,two,three,four,five'
print(s_comma.split(','))
print(s_comma.split('three'))
import re
text = "python is, an easy;language; to, learn."
print(re.split("[;,] ", text))
import re
text = "python is, an easy;language; to, learn."
separators = "; ", ", "
def custom_split(sepr_list, str_to_split):
regular_exp = '|'.join(map(re.escape, sepr_list))
return re.split(regular_exp, str_to_split)
print(custom_split(separators, text))