Skip to content

Instantly share code, notes, and snippets.

@THE-FYP
Last active June 21, 2018 09:15
Show Gist options
  • Save THE-FYP/4d245742ea05980d5e767a8ccb6e9f00 to your computer and use it in GitHub Desktop.
Save THE-FYP/4d245742ea05980d5e767a8ccb6e9f00 to your computer and use it in GitHub Desktop.
function split(str, delim, plain)
local lines, pos, plain = {}, 1, not (plain == false) --[[ delimiter is plain text by default ]]
repeat
local npos, epos = string.find(str, delim, pos, plain)
table.insert(lines, string.sub(str, pos, npos and npos - 1))
pos = epos and epos + 1
until not pos
return lines
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment