Так же, как string.gmatch
найдет шаблоны в строке, эта функция найдет вещи между шаблонами :
function string:split(pat)
pat = pat or '%s+'
local st, g = 1, self:gmatch("()("..pat..")")
local function getter(segs, seps, sep, cap1, ...)
st = sep and seps + #sep
return self:sub(segs, (seps or 0) - 1), cap1 or sep, ...
end
return function() if st then return getter(st, g()) end end
end
По умолчанию он возвращает все, что разделено пробелами.