Hi, given a string like "ProductA 1 Product B 1 2 3 ProductC 10 20 50" I need to obtain a list of products and a list of corresponding numbers related to each product.
The first list is easy to obtain:
s = "ProductA 1 Product B 1 2 3 ProductC 10 20 50"
p = re.compile(u"[a-zA-Z]+")
p.findall(s)
["ProductA", "ProductB", "ProductC"]
Now the second list should be done this way:
["1", "1 2 3", "10 20 50"]
I tried using this regex but it didn't work: (\s+\d+\s*)+ because findall returns [' 1 ', ' 1 ', ' 3 ', ' 10 ', ' 30'] which is totally unuseful to me. I also tried to change regex to (\s+\d+\s*)+? which enables greedy, but still wrong result.
Do you have any hint... or a solution? ;)
Thanks!