fork download
  1. import re
  2. text = "Compared to 2019, the revenue increased from 934,000$ to 1.5 million$ in 2020."
  3. rx = r'(?:^|\s)(?=.)((?:0|(?:[1-9](?:\d*|\d{0,2}(?:,\d{3})*)))?(?:\.\d*[1-9])?)(?!\S)'
  4. print(re.findall(rx, text))
Success #stdin #stdout 0.02s 9664KB
stdin
Standard input is empty
stdout
['1.5']