Similar to this question I have a string of names and numbers separated by a colon:
s = 'Waz D: 5 l gu l: 5 GrinVe: 3 P LUK: 2 Cubbi: 1 2 nd dok: 1 maf 74: 1 abr12: 1 Waza D 5'
I'm trying to split this to get:
('Waz D', '5'),
('l gu l', '5'),
('GrinVe', '3'),
('P LUK', '2'),
('Cubbi', '1'),
('2 nd dok', '1')
('maf 74', '1')
('abr12', '1')
I have tried two regular expressions so far with mixed success:
re.findall(r"(.*?)[a-zA-Z0-9]+: (\d+)*", s)
[('Waz ', '5'),
(' l gu ', '5'),
(' ', '3'),
(' P ', '2'),
(' ', '1'),
(' 2 nd ', '1'),
(' maf ', '1'),
(' ', '1')]
And:
re.findall(r"(.*?)([a-zA-Z0-9]+): (\d+)*", s)
[('Waz ', 'D', '5'),
(' l gu ', 'l', '5'),
(' ', 'GrinVe', '3'),
(' P ', 'LUK', '2'),
(' ', 'Cubbi', '1'),
(' 2 nd ', 'dok', '1'),
(' maf ', '74', '1'),
(' ', 'abr12', '1')]
How can I adjust this to get the output I'm after?