I have the following line:
mystring = "a=test;b=12345"
I would like to know how to initialize a table with one shot, assign it a row value. The string is taken from another external application, and if possible, I want to avoid splitting it. Something like that:
mytable = {mystring:gsub(";",",")}
Is it possible to do something like this? I know how to do this in a few steps ... but just wondering if it's possible to do it all at once.
Here is what I tried and the corresponding output:
> mystring = "a=123;b=2345"
> myarray = {mystring:gsub(";",",")}
> for key,value in pairs(myarray) do print(key,value) end
1 a=123,b=2345
2 1
>
whereas I was hoping to get an array / table, for example:
key value
a 123
b 2345
source
share