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,完善。