function split(str,sp) local result = {} local i = 0 local j = 0 local num = 1 local pos = 0 while true do i , j = string.find(str,sp,i+1) if i == nil then if num ~=1 then result[num] = string.sub(str,pos,string.len(str)) end break end result[num] = string.sub(str,pos,i-1) pos = i+string.len(sp) num = num +1 end return result end
lua本身没有Split功能,很不方便,所以自己实现了一个
原文地址:https://www.cnblogs.com/dccat/p/8870505.html
时间: 2024-12-18 07:45:17