fork(1) download
  1. import re
  2. text = "$1.234.567,89 gjhv $1.02 $1.203,20 ghjb $1.205 $63"
  3. numbers_list = ['$1,234,567.89', '$1.02', '$1,203.20', '$1,205', '$63']
  4. it = iter(numbers_list)
  5.  
  6. def replacer(match):
  7. return next(it)
  8.  
  9. print(re.sub(r'\$\d[\d,.]*\b', replacer, text))
Success #stdin #stdout 0.02s 6872KB
stdin
Standard input is empty
stdout
$1,234,567.89 gjhv $1.02 $1,203.20 ghjb $1,205 $63