fork download
  1. import re
  2. rx = r"Total Change is:\s*\S+|Changes from:.*?\d{4}\b|([-+]?\d+(?:,\d+)?)"
  3. text = "Changes from: August 18, 2020 Total Change is: -3,029\n\n 0 -2,872 -18 898 870 -200 -2,819 -311 -112 0 2 0 -778 -388"
  4. results = [x for x in re.findall(r'Total Change is:\s*\S+|Changes from:.*?\d{4}\b|([-+]?\d+(?:,\d+)?)', text) if x]
  5. print(results)
  6.  
Success #stdin #stdout 0.02s 9632KB
stdin
Standard input is empty
stdout
['0', '-2,872', '-18', '898', '870', '-200', '-2,819', '-311', '-112', '0', '2', '0', '-778', '-388']