Lua实现split函数
时间:2021-04-19 08:07:20|栏目:|点击: 次
function split(s, delim)
if type(delim) ~= "string" or string.len(delim) <= 0 then
return
end
local start = 1
local t = {}
while true do
local pos = string.find (s, delim, start, true) -- plain find
if not pos then
break
end
table.insert (t, string.sub (s, start, pos - 1))
start = pos + string.len (delim)
end
table.insert (t, string.sub (s, start))
return t
end
上一篇:使用ZeroClipboard解决跨浏览器复制到剪贴板的问题
栏 目:
下一篇:易语言打开文件件网页的方法
本文标题:Lua实现split函数
本文地址:http://www.codeinn.net/misctech/104374.html






