Skip to content

Instantly share code, notes, and snippets.

@shakesoda
Created June 21, 2012 18:23
Show Gist options
  • Save shakesoda/2967558 to your computer and use it in GitHub Desktop.
Save shakesoda/2967558 to your computer and use it in GitHub Desktop.
function split(s, v)
local pos = s:find(v)
local ret = {}
local idx = 1
for i=1,string.len(s) do
local c = s:sub(i,i)
local token = s:sub(i, i+v:len()-1)
if token:find(v) then
idx = idx + 1
else
if ret[idx] == nil then ret[idx] = "" end
ret[idx] = ret[idx] .. c
end
end
return ret
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment