fork download
  1. import re
  2. text = "5 000, 6 123 456,345 and 6 123 456.345... I mean 20 000 or 5 000 000. For example: 20 30"
  3. print( re.findall(r'(?<!\d)(?<!\d[.,])\d{1,3}(?:\s\d{3})*(?:[,.]\d+)?', text) )
Success #stdin #stdout 0.02s 9628KB
stdin
Standard input is empty
stdout
['5 000', '6 123 456,345', '6 123 456.345', '20 000', '5 000 000', '20', '30']