Skip to content

Instantly share code, notes, and snippets.

@CapsAdmin
Created September 27, 2018 11:46
Show Gist options
  • Save CapsAdmin/18b1390af482b809d64900e058e68ea9 to your computer and use it in GitHub Desktop.
Save CapsAdmin/18b1390af482b809d64900e058e68ea9 to your computer and use it in GitHub Desktop.
local function split_line(self, separator, plain_search)
if plain_search == nil then
plain_search = true
end
local tbl = {}
local current_pos = 1
for i = 1, #self do
local start_pos, end_pos = self:find(separator, current_pos, plain_search)
if not start_pos then break end
tbl[i] = self:sub(current_pos, start_pos - 1)
current_pos = end_pos + 1
end
if current_pos > 1 then
tbl[#tbl + 1] = self:sub(current_pos)
else
tbl[1] = self
end
return tbl
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment