How to correct gsub?

local str = "1000ki"
    print(str:gsub('[^%d.]', ''))

conditionally I get a string, and on the printer I get 1000 2
As I understand it, the last digit is how many characters were deleted. But how do I get rid of this character as well

Either you could do it like this:

local str = "1000ki"
local gsubStr = str:gsub('[^%d.]', '')
print(gsubStr)

or if you really want to use one line:

local str = "1000ki"
print(({str:gsub('[^%d.]', '')})[1])
1 Like

Thx. That help me. I understand what iā€™m doing wrong

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.