fork download
  1. import re
  2. s = '19 Aug standing order rent Apolo Housing Assoc. 500.00 50.00\n20 Aug transfer from John wick saving a/c 200.00 130.90'
  3. w = 'rent'
  4. rx = fr'\b{w}\D+(\d+(?:[,.]\d+)*)'
  5. m = re.search(rx, s)
  6. if m:
  7. print(f'{w} {m.group(1)}')
Success #stdin #stdout 0.03s 9332KB
stdin
Standard input is empty
stdout
rent 500.00