I have data that looks like this:
data = '5.2 -34 435, 34 2.908 3, 50 2 54 3, 40 50'
I am trying to write a regex such that each items in a Python list created by re.findall only contains 3 or less numbers bounded by the commas as shown above.
If there are more than 3 numbers bounded by commas, then place the remaining numbers before comma in the next item within a list (as long as it's less than or equal to 3)
Ideally the output for the above data would look like this
['5.2 -34 435','34 2.908 3','50 2 54','3','40 50']
I tried to write up the following looking at tutorials but it doesn't seem to work too well...
re.findall(r"[-+A-z0-9.\s]{3}", data)