Skip to content

Instantly share code, notes, and snippets.

@farhaven
Created March 7, 2010 17:44
Show Gist options
  • Save farhaven/324503 to your computer and use it in GitHub Desktop.
Save farhaven/324503 to your computer and use it in GitHub Desktop.
function split(str)
local values = { }
local idx_s = 0
local idx_e = 0
while idx_e ~= nil do
idx_s = idx_e + 1
idx_e = str:find("[ \n]", idx_s)
local sub = str:sub(idx_s, idx_e and idx_e - 1 or nil)
if sub ~= "" then
table.insert(values, sub)
end
end
return values
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment