Answers for "split string with 2 delimiters python"

5

multi split python

str = 'Lorem; ipsum. dolor sit amet, consectetur adipiscing elit.'
str = str.split(',')
print(str) # Output ['Lorem; ipsum. dolor sit amet', ' consectetur adipiscing elit.']

import re
str = 'Lorem; ipsum. dolor sit amet, consectetur adipiscing elit.'
str = re.split(r';|,|.', str)
print(str) # Output ['Lorem', ' ipsum', ' dolor sit amet', ' consectetur adipiscing elit', '']
Posted by: Guest on May-04-2020
10

how to split a string in python with multiple delimiters

>>> a='Beautiful, is; better*thannugly'
>>> import re
>>> re.split('; |, |*|n',a)
['Beautiful', 'is', 'better', 'than', 'ugly']
Posted by: Guest on June-09-2020
0

python split string keep delimiter

line = "<html><head>"
d = ">"
s =  [e+d for e in line.split(d) if e]
print(s)
#Output:
#["<html>", "<head>"]
Posted by: Guest on December-23-2020

Code answers related to "split string with 2 delimiters python"

Python Answers by Framework

Browse Popular Code Answers by Language