标签:
function string_split(str, delimiter)
if str == nil or str == ‘‘ or delimiter == nil then
return nil
end
local result = {}
for match in (str..delimiter):gmatch("(.-)"..delimiter) do
table.insert(result, match)
end
return result
end
local tbl = string_split("aaaaacdddddzzzz", "c")
for k, v in pairs(tbl) do
print(k ,v )
end
输出结果:
> dofile "123.lua"
1 aaaaa
2 dddddzzzz
>
标签:
原文地址:http://www.cnblogs.com/HemJohn/p/5815990.html