Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

re.split

import re
text = "python is, an easy;language; to, learn."
separators = "; ", ", "


def custom_split(sepr_list, str_to_split):
    # create regular expression dynamically
    regular_exp = '|'.join(map(re.escape, sepr_list))
    return re.split(regular_exp, str_to_split)


print(custom_split(separators, text))
Source by www.delftstack.com #
 
PREVIOUS NEXT
Tagged:
ADD COMMENT
Topic
Name
7+7 =