I'm scraping prices and I want to ensure the price string doesn't contain anything such as:
- Whitespaces
- Letters
- More than one decimal
- Special characters such as commas
Right now I'm starting to do something like:
def parse_price(price):
price = price.replace(' ', '')
price = price.replace(',', '')
return price
Which I don't like the look of.
Allowed:
1.00
432.32
32324.03
Not allowed:
$1.00
3.43
C$32.55
£16.43
324,4343.20