1str = 'Lorem; ipsum. dolor sit amet, consectetur adipiscing elit.'
2str = str.split(',')
3print(str) # Output ['Lorem; ipsum. dolor sit amet', ' consectetur adipiscing elit.']
4
5import re
6str = 'Lorem; ipsum. dolor sit amet, consectetur adipiscing elit.'
7str = re.split(r';|,|\.', str)
8print(str) # Output ['Lorem', ' ipsum', ' dolor sit amet', ' consectetur adipiscing elit', '']
1>>> a='Beautiful, is; better*than\nugly'
2>>> import re
3>>> re.split('; |, |\*|\n',a)
4['Beautiful', 'is', 'better', 'than', 'ugly']
1line = "<html><head>"
2d = ">"
3s = [e+d for e in line.split(d) if e]
4print(s)
5#Output:
6#["<html>", "<head>"]
1>>> a='Beautiful, is; better*than\nugly'
2>>> import re
3>>> re.split('; |, |\*|\n',a)
4['Beautiful', 'is', 'better', 'than', 'ugly']
5
1#Do a str.replace('? ', ', ') and then a str.split(', ')
2#Example:
3a = "Hello, what is your name? I'm Bob."
4a.replace('? ', ', ')
5print(a)
6#"Hello, what is your name, I'm Bob."
7a.split(", ")
8print(a)
9#["Hello", "what is your name", "I'm Bob."]