fork download
  1. import re
  2. rx = r"\(E\d+\)|([^\W\d]+(?:\s+[^\W\d]+)*)"
  3. s = "Pork and beef, water, salt (1,7%), spices (white pepper, nutmeg, coriander, cardamom), stabilizer (E450), glucose, antioxidant (E316), a preservative (E250), flavorings"
  4. res = [x for x in re.findall(rx, s) if x]
  5. print(res)
Success #stdin #stdout 0.01s 9024KB
stdin
Standard input is empty
stdout
['Pork and beef', 'water', 'salt', 'spices', 'white pepper', 'nutmeg', 'coriander', 'cardamom', 'stabilizer', 'glucose', 'antioxidant', 'a preservative', 'flavorings']