Lua string split分割字符串

-- 分隔字符串
function string:split(sep)
    local sep, fields = sep or "\t", {}
    local pattern = string.format("([^%s]+)", sep)
    self:gsub(pattern, function(c) fields[#fields+1] = c end)
    return fields
end


你可能感兴趣的:(Lua string split分割字符串)