Computer Science, asked by kriz8825, 1 year ago

How do we use a delimiter to split string in Python regular expression?

Answers

Answered by pandeysakshi2003
0

Tutorialspoint

Search your favorite tutorials...

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

How can I use Python regex to split the following string by multiple delimiters like ',', ':', '\n' and '*'?

s = 'Beautiful; Soup\n is, good: Python* application'

Follow Answer 1003

1 Answer

Rajendra Dharmkar

Rajendra Dharmkar

Answered on 11th Jan, 2018

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

import re

s = 'Beautiful; Soup\n is, good: Python* application'

result = re.split('; |, |\*|\n|:',s)

print result

This gives the output

['Beautiful', 'Soup', ' is', 'good',

please make me brainlist

Similar questions