local function Split2(szFullString, szSeparator)

local nFindStartIndex = 1

local nSplitIndex = 1

local nSplitArray = {}

while true do

local nFindLastIndex = string.find(szFullString, szSeparator, nFindStartIndex)

if not nFindLastIndex then

nSplitArray[nSplitIndex] = string.sub(szFullString, nFindStartIndex, string.len(szFullString))

break

end

nSplitArray[nSplitIndex] = string.sub(szFullString, nFindStartIndex, nFindLastIndex - 1)

nFindStartIndex = nFindLastIndex + string.len(szSeparator)

nSplitIndex = nSplitIndex + 1

end

return nSplitArray



用法:

local recvDatas= Split2(s,",")
NET.state= tonumber(recvDatas[1])--一定要从1开始