diff --git a/stringx.lua b/stringx.lua index 9ec19e1..3752d63 100644 --- a/stringx.lua +++ b/stringx.lua @@ -49,18 +49,20 @@ function stringx.split(self, delim, limit) for j = 2, delim_length do if self:byte(i + j - 1) ~= delim:byte(j) then has_whole_delim = false + --step forward as far as we got + i = i + j break end end if has_whole_delim then if #res < limit then table.insert(res, i) + --iterate forward the whole delimiter + i = i + delim_length else break end end - --iterate forward - i = i + delim_length else --iterate forward i = i + 1