fork download
  1. import re
  2.  
  3. texts = ['03-23-27-34-37, Mega Ball: 13', '01-12 + 08-20', '04-15-17-25-41']
  4. reg = re.compile(r'^(?:[^\w,]*\d+)+')
  5.  
  6. for text in texts:
  7. match = reg.search(text)
  8. if match:
  9. print( text, '=>', list(map(int,re.findall(r'\d+', match.group()))) )
Success #stdin #stdout 0.02s 9552KB
stdin
Standard input is empty
stdout
03-23-27-34-37, Mega Ball: 13 => [3, 23, 27, 34, 37]
01-12 + 08-20 => [1, 12, 8, 20]
04-15-17-25-41 => [4, 15, 17, 25, 41]