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

PythonServer Side ProgrammingProgramming

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']
raja
Published on 11-Jan-2018 11:58:43
Advertisements