Lua table String.Format (SOLVED)

Hi,

If I do a for loop how would I go about getting only the letters and not the numbers in the string from the key?

local usernames = {}

local function http_result(self, id, response)
    local j = json.decode(response.response)

    for key,value in pairs(j) do
        -- only get the letters of the string per key
    end
end

I got the numbers removed my using string.gsub.

for key,value in pairs(j) do
    print(string.gsub(j[key], '%d', ''))
end

To make it more fool-proof, you could remove any non-letter characters with the pattern “%A”.

1 Like