getting several substrings in a string and storing them in a table

Please help.
I want to get the values of some parameters in a url, Ii know the idea but I dont know how to do get them. I was using an lib to do it, but in android it doesnt work so I am trying to do it manually.
I have an string that is an url:

local url=“fbconnect://success?**to[**0]= 293321147507203 &**to[**1]= 293321147507202 &request=528210977333164”

I want to detect the substrings to[ and get the numbers 293321147507203,293321147507202 and store them in a table.

I know the process is detect the substring to[ and then get the substring that is 3 character (or 6 not sure if it counts from the begining of “to[” and then get the number, always is a 15 digit number.

Please help. I am bad with this complex process of recurrency.

Look up the lua match function. This works but destroys the url string.

local url="fbconnect://success?to[0]=293321147507203&to[1]=293321147507202&request=528210977333164" local table = {} repeat toIndex,toItem,url = url:match("to%[(%d+)]%=(%d+)(.\*)") if url ~= nil then table[tonumber(toIndex)] = toItem end until url == nil

It will put the first long number in table[0], then second in table[1] - stores them as strings but easily changed.

Thanks, i got the solution:

 

local url="fbconnect://success?to[0]=213325147507203&to[1]=2233211475307202&request=524210917333164" local some\_table = {} for i, v in url:gmatch'to%[(%d+)]=(%d+)' do some\_table[tonumber(i)] = v -- store value as string end print(some\_table[0], some\_table[1]) --\> 213322147507203 223321147507202

Look up the lua match function. This works but destroys the url string.

local url="fbconnect://success?to[0]=293321147507203&to[1]=293321147507202&request=528210977333164" local table = {} repeat toIndex,toItem,url = url:match("to%[(%d+)]%=(%d+)(.\*)") if url ~= nil then table[tonumber(toIndex)] = toItem end until url == nil

It will put the first long number in table[0], then second in table[1] - stores them as strings but easily changed.

Thanks, i got the solution:

 

local url="fbconnect://success?to[0]=213325147507203&to[1]=2233211475307202&request=524210917333164" local some\_table = {} for i, v in url:gmatch'to%[(%d+)]=(%d+)' do some\_table[tonumber(i)] = v -- store value as string end print(some\_table[0], some\_table[1]) --\> 213322147507203 223321147507202