fork download
  1. import re
  2. text = '4.5 $55 1,200 wordA 3 sometext 2 wordB sometext 4.3charA sometext charB21.6 sometext 11/10/22 123,567,445, $120,990,000 $40,432,123,234.505 345678'
  3. rx = r'(?<!\d)\d{1,2}/\d{1,2}/\d{2}(?:\d{2})?(?!\d)|\b(?:charB|wordA)\s*\d*[.,]?\d+|(?<!\d[.,])(?<!\d)((?:\d{1,3}(?:[.,]\d{3})*|\d+)(?:\.\d+)?)(?!\s*(?:wordB|charA)|[.,]?\d)'
  4. matches = re.findall(rx, text)
  5. print( [ m for m in matches if m ] )
Success #stdin #stdout 0.04s 9520KB
stdin
Standard input is empty
stdout
['4.5', '55', '1,200', '123,567,445', '120,990,000', '40,432,123,234.505', '345678']