lua DIY split函数
发布时间:2020-12-14 21:55:10 所属栏目:大数据 来源:网络整理
导读:function split(val,delimiter) local matches = {} if val == nil or val == '' or val == 0 or val == false then table.insert(matches,nil) -- #matches = 0 elseif delimiter == '' then table.insert(matches,val) -- #matches = 1 else if not string
function split(val,delimiter) local matches = {} if val == nil or val == '' or val == 0 or val == false then table.insert(matches,nil) -- #matches = 0 elseif delimiter == '' then table.insert(matches,val) -- #matches = 1 else if not string.match(val,delimiter) then table.insert(matches,val) -- #matches = 1 else string.gsub(val,"[^"..delimiter.."]+",function(c) matches[#matches+1] = c end) -- #matches = n end end return matches end 欢迎debug,完善。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |