lua 拆分字符
function StringTool:split( str_, limit_, type_ )
if str_ == nil or str_ == "" then
LogInfo("StringTool:split wrong string")
return nil
end
if limit_ == nil or limit_ == "" then
LogInfo("StringTool:split wrong limit")
return nil
end
local pos = 0
local valueTbl = {}
while pos ~= nil do
local value
local _next = string.find(str_, limit_, pos + 1)
if _next ~= nil then
value = string.sub(str_, pos + 1, _next - 1)
elseif pos ~= string.len(str_) then
value = string.sub(str_, pos + 1, string.len(str_))
end
if value then
if type_ == "int" then
value = tonumber(value)
end
table.insert(valueTbl, value)
end
pos = _next
end
return valueTbl
end