Lua table String.Format (SOLVED)

#1

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
0 Likes

#2

I got the numbers removed my using string.gsub.

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

#3

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

1 Like