I am newbie in Regular expressions,I want to extract amount from a given text,Here is my code:
import pandas as pd
import re
msg='He was paid USD 2,000.00 & USD 500 on 19-02-2018 at 08:15:24.'
pattern = re.compile(r'USD\s+(\d+)')
matches = pattern.finditer(msg)
for match in matches:
print(match)
I want output as 2000 and 500,But currently I am getting USD 2 as output.Please help. Note:The original message is very long but all the amounts have USD preceding them.