How to remove other characters from a string to turn it into number

So im using Steam Marketplace API to get prices of items but i cant convert it to number cuz it returns “80,–€” instead of just a number. I also want it to turn the “,” into a dot cuz i want cents also count but i dont know how to do it.

function formattedPriceToNumber(price)
    return tonumber( price:gsub(',', '.'):match("%d+%.%d*") )

Although I’d look into the API to see if you can get prices in a specified locale and find a locale that uses . for decimal separator instead of , (e.g. en-US)

1 Like