Hello! I'm trying to make a table that will contain nothing. I want to cut a piece of text, (that's not what I'm asking) and I want to split that string into a table. Example:
table = {} split(table, text) print(table) -- prints: "t", "e", "x", "t"
Thank you so much for any little help!
I can think of two ways to do this.
First, you can just add each character to a table with a simple loop using string.sub
.
local function Split(String) local Table = {} for I = 1, #String do table.insert(Table, string.sub(String, I, I)) end return Table end Split("Test") -- > {"T", "e", "s", "t"}
Alternatively you could use string.split
.
string.split("Test", "") -- > {"T", "e", "s", "t"}
Good luck!