Hi all, I have one question.
I want to store this string in number array: “1,2,10,31”
How do I do it, please help?
Hi all, I have one question.
I want to store this string in number array: “1,2,10,31”
How do I do it, please help?
lua has a “concat” but no dedicated “split”, but you can diy with string.gmatch, fe:
local fullstring = "1,2,10,31" local pattern = "([^,]+)" -- read docs to learn this magic numbers = {} for snippet in fullstring:gmatch(pattern) do numbers[#numbers+1]=tonumber(snippet) end for i=1,#numbers do print(numbers[i]) end
THANKS x13424324 SIR, you saved my app !
lua has a “concat” but no dedicated “split”, but you can diy with string.gmatch, fe:
local fullstring = "1,2,10,31" local pattern = "([^,]+)" -- read docs to learn this magic numbers = {} for snippet in fullstring:gmatch(pattern) do numbers[#numbers+1]=tonumber(snippet) end for i=1,#numbers do print(numbers[i]) end
THANKS x13424324 SIR, you saved my app !