In Lua, is there any way to split this string:
etc3=1336,etc2=14477,etc4=1335,etc1=1337
into this table?
tbl = {
{ 'etc3', 1336 },
{ 'etc2', 14477 },
{ 'etc4', 1335 },
{ 'etc1', 1337 },
}
Any help is appreciated.
local str = 'etc3=1336,etc2=14477,etc4=1335,etc1=1337'
local tbl = {}
for k, v in str:gmatch'(%w+)=(%d+)' do
tbl[#tbl+1] = {k, tonumber(v)}
end