Created
February 9, 2016 00:02
-
-
Save farrajota/23cadab5eb13c3ef296b to your computer and use it in GitHub Desktop.
split strings by any type of separator in Lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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