import re s = """I want a (hot chocolate)[food] and (two)[quantity] boxes of (crispy bacon)[food]""" print(re.split(r'\s(?!\w+\))',s))
Standard input is empty
['I', 'want', 'a', '(hot chocolate)[food]', 'and', '(two)[quantity]', 'boxes', 'of', '(crispy bacon)[food]']