I'm making a program that takes currency from a string and converts it in to other currencies. For example, if the string was 'the car cost me $13,250'
I would need to get $
and 13250
. I have this regex already (?:\£|\$|\€)(?:.{1,})
that sort of does it, however there is a reasonably large possibility that the string might have more than one price, all using different currencies. This is something that I do no know how to do effectively.
What I need to know is how to extract all of the prices from a string. I think even if the regex just returns something like ['$12,250,000','£14,500,123','£120.25']
then it is fine because I can use something like this to get the number:
prices = ['$12,250','£14,500','£120']
for value in prices:
value.replace(',','')
And something like this to get the currency:
for c in prices:
currency = c[0]
Then there is the problem that the price might not be a whole number, and might be something like $12.54
. Any help on how to get that initial list of prices would be great.