lua split函数

来源:互联网 发布:普法网络知识竞赛答题 编辑:程序博客网 时间:2024/05/29 18:36

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 tend



0 0
原创粉丝点击