Skip to content

Instantly share code, notes, and snippets.

@hailinzeng
Created April 15, 2013 08:28
Show Gist options
  • Save hailinzeng/5386709 to your computer and use it in GitHub Desktop.
Save hailinzeng/5386709 to your computer and use it in GitHub Desktop.
string split
function split(str,delim)
local i,j,k
local t = {}
k = 1
while true do
i,j = string.find(str,delim,k)
if i == nil then
table.insert(t,string.sub(str,k))
return t
end
table.insert(t,string.sub(str,k,i - 1))
k = j + 1
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment