Jun-16-2021, 12:13 PM
I'm not a regex expert, but the following code might help you
import re # line = " 0 2 0 -15000 0" line = "50 2 2 -14950 3" Values = re.split(r"\s?([+\-]?\d+)\s+([+\-]?\d+)\s+([+\-]?\d+)\s+([+\-]?\d+)\s+([+\-]?\d+)", line) print(f"1rst value : {Values[1]}") print(f"2nd value : {Values[2]}") print(f"3rd value : {Values[3]}") print(f"4th value : {Values[4]}") print(f"5th value : {Values[5]}")