Let’s say I have a fraction within a string: “1/2”.
If I use the tonumber() on that string, it should return 0.5, but instead it returns nil because of the division sign.
Is there any other way I could convert string with fractions in them into numbers?
local fraction = "1/2"
local number = tonumber(fraction)
print(number) -- should return 0.5, actually returns nil
Ok, first let’s check for a division symbol and get back and next letters and check if they are numbers if so tostring back and next letters to numbers and divide them.