fork download
  1. import re
  2. txt = "123 4 56-7 maine x1s56"
  3. x = re.findall(r"\d+(?:\s|(?=-))", txt)
  4. print(x) # => ['123 ', '4 ', '56', '7 ']
Success #stdin #stdout 0.03s 9268KB
stdin
Standard input is empty
stdout
['123 ', '4 ', '56', '7 ']