Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Beispiel/example
- -- local test = string.split(string , separator)
- -- local vert1 = test[1]
- -- local vert2 = test[2]
- -- ...
- function string:split(sSeparator, nMax, bRegexp)
- assert(sSeparator ~= '')
- assert(nMax == nil or nMax >= 1)
- local aRecord = {}
- if self:len() > 0 then
- local bPlain = not bRegexp
- nMax = nMax or -1
- local nField=1 nStart=1
- local nFirst,nLast = self:find(sSeparator, nStart, bPlain)
- while nFirst and nMax ~= 0 do
- aRecord[nField] = self:sub(nStart, nFirst-1)
- nField = nField+1
- nStart = nLast+1
- nFirst,nLast = self:find(sSeparator, nStart, bPlain)
- nMax = nMax-1
- end
- aRecord[nField] = self:sub(nStart)
- end
- return aRecord
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement