local function tokenize(param)
local tokens = {};
local function getmatch(match)
table.insert(tokens, match);
return '';
end
local old = param;
while param and param ~= '' do
if param:match'^"' then
param = string.gsub(param, '^"([^"]*)"%s*', getmatch);
else
param = string.gsub(param, '^([^%s"]+)%s*', getmatch);
end
if param == old then
getmatch(param);
break;
end
old = param;
end
return tokens;
end
for _, t in ipairs(tokenize([["hi there" "what there" 3 003 "bob's your uncle" bye!]])) do print(t); end