Created
September 27, 2018 11:46
-
-
Save CapsAdmin/18b1390af482b809d64900e058e68ea9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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