Computer >> Computer tutorials >  >> Programming >> Python

How can I use Python regex to split a string by multiple delimiters?


The following code uses Python regex to split the given string by multiple deliimiters

Example

import re
s = 'Beautiful; Soup\n is, good: Python* application'
result = re.split('; |, |\*|\n|:',s)
print result

Output

This gives the output

['Beautiful', 'Soup', ' is', 'good', ' Python', ' application']