fork(1) download
  1. import re
  2. s = """aaa 111(zzz)
  3. 222
  4. 333
  5. bbb 555
  6. 111"""
  7. rx= r'^(\S+)\s+(.*(?:[\r\n]+ +.*)*)'
  8. res =[]
  9. for m in re.finditer(rx, s, re.M):
  10. res.append((m.group(1), re.findall(r"[0-9]+", m.group(2))))
  11. print(res)
Success #stdin #stdout 0s 23304KB
stdin
Standard input is empty
stdout
[('aaa', ['111', '222', '333']), ('bbb', ['555', '111'])]