string.split(str, separator)
Splits a string into substrings by a separator.
Parameters
str
The string
that will be divided into substrings.
separator
A string
that will be used as a separator to divide the string into substrings.
Return value
Returns a list of substrings as atable
.
Example
-- Lua string.split example
local console = require "console"
local str = "Hello[space]World[space]by[space]LuaRT[space]!"
for word in each(str:split("[space]")) do
console.write(word.." ")
end