How do we use a delimiter to split string in Python regular expression?
Answers
Answered by
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
Hindi,
6 months ago
Computer Science,
6 months ago
Social Sciences,
6 months ago
Environmental Sciences,
1 year ago