How can I split a string on every third space? I'm wondering if python has built-in syntax for this or if it can be done using a list comprehension.
"a bb c dd ee f" -> ["a bb c", "dd ee f"]
re.split(r'(.*?\s.*?\s.*?)\s', "a bb c dd ee f")
and in order to remove empty strings from the result:
[x for x in re.split(r'(.*?\s.*?\s.*?)\s', "a bb c dd ee f") if x]
re.split(r'(.*?\s.*?\s.*?)\s', "a bb c dd ee f")[1:]
re.findall(r'\S+\s\S+\s\S+', "a bb c dd ee f")