function split(input, delimiter)
input = tostring(input)
delimiter = tostring(delimiter)
if (delimiter=='') then return false end
local pos,arr = 0, {}
-- for each divider found
local function test() return string.find(input, delimiter, pos, true) end
local tmp1,tmp2 = test();
for st,sp in function() return string.find(input, delimiter, pos, true) end do
table.insert(arr, string.sub(input, pos, st - 1))
pos = sp + 1
end
table.insert(arr, string.sub(input, pos))
return arr
end
local arr = split(str,delStr);
local tm = table.insert( arr, "123")
字符串分割选自 cocos中的function.lua函数
下一篇介绍 for <var_list> in <exp_list> do end 语法使用。