Here's a string that I'm trying to parse in python
s1="One : Two : Three : Four Value : Five Value : Six Value : Seven Value : Eight Value :"
Can someone tell me a re function I can use to parse the above string so that s1 becomes as follows without any ':'
One
Two
Three
Four Value
Five Value
Six Value
Seven Value
Eight Value
I've tried making use of strip, lstrip and rstrip after spliting the string by using the following code but I don't get the format I need
res1=s1.split(' : ')
UPDATE: Thanks a lot for your answers but the output I'm getting looks like this whether I use
1->
for index in s1:
print index
or....
2->
pprint(s1)
OUTPUT:
O
n
e
:
T
w
o
:
T
h
r
e
e
:
F
o
u
r
V
a
l
u
e
:
F
i
v
e
V
a
l
u
e
:
S
i
x
V
a
l
u
e
:
S
e
v
e
n
V
a
l
u
e
:
E
i
g
h
t
V
a
l
u
e
:
filter(lambda x: x != '', [item.strip() for item in s1.split(':')])or[item.strip() for item in s1.split(':') if item.strip() != '']or[item for item in map(lambda x: x.strip(), s1.split(':')) if item != '']for index in s1:instead offor index in res1: