描述:根据分割符 splitStr 将字符串 str 进行分割
time="小怪:10分钟 精英:20分钟 BOSS:30分钟"function StringSplit(str,splitStr, showSplitStr)local startPos = 1local strTab = {}while true dolocal strChild = ""local startPos,endPos = string.find(str,splitStr)if not startPos then startPos = 0endPos = 0 endstrChild = string.sub(str,1,startPos-1)if showSplitStr and #strTab > 0 thenstrChild = splitStr..strChildendtable.insert(strTab, strChild)str = string.sub(str,endPos+1,-1)if startPos and startPos == 0 thenbreakendendreturn strTab
endstrTab = StringSplit(time,", true)
for i,v in ipairs(strTab) doprint(i,v)
end