Lua string.split

This article is tagged with: Lua string.split and lua

lua string.split

function Split(s, delimiter)
result = {};
for match in (s..delimiter):gmatch("(.-)"..delimiter) do
table.insert(result, match);
end
return result;
end
split_string = Split("Hello World!", " ")
-- split_string[1] = "Hello"
-- split_string[2] = "World!"

This article is tagged with: Lua string.split and lua