samedi 25 avril 2015

How to get value of numbers with space


I used to have strings like this:

233.43 USD
634,233 EURO

and I used to extract numbers from those strings using this:

def extractNumbersFromString(value): #This function is to get the numbers froma string
        return re.search('(\d+(?:[.,]\d*)*)', value).group(1)

Now I got strings like these as well:

2300 000 USD
430 000 EU

where there is a space between the numbers and the zeros on the right.

How can I adjust my code to extract the numbers from those strings?

Required output:

 2300000 
 430000 

My code currently gives me just this 2300 and 430 (i.e. without the zeros on the right).


Aucun commentaire:

Enregistrer un commentaire