Search code examples
pythonweb-scrapingdata-analysis

Remove currency in stock price scraping


I scrape an stock price from an website and the output ist e.g. "12 EUR". How can i remove the EUR from the string inpython , so that i can work with just the number?

Thanks a lot!


Solution

  • Use regex to remove anything that is not a number.

    import re
    stock = '12 EUR'
    stock = re.sub('[^0-9]', '', stock)