Skip to content

Instantly share code, notes, and snippets.

@farrajota
Created February 9, 2016 00:02
Show Gist options
  • Save farrajota/23cadab5eb13c3ef296b to your computer and use it in GitHub Desktop.
Save farrajota/23cadab5eb13c3ef296b to your computer and use it in GitHub Desktop.
split strings by any type of separator in Lua
local function mysplit(inputstr, sep)
-- split strings by any type of separator
if sep == nil then
sep = "%s"
end
local t={} ; i=1
for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
t[i] = str
i = i + 1
end
return t
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment