Im making some dumb thing... again welp
I ran into a problem
I need to convert a string to a array
Code: Select all
a = "This is a string :)"
b = {"T", "h", "i", "s"} --[[ you get the idea]]--
Every help is appreciated
Code: Select all
a = "This is a string :)"
b = {"T", "h", "i", "s"} --[[ you get the idea]]--
Code: Select all
astring = "pog"
print(astring)
--pog
Code: Select all
str:gsub(".",function(c) table.insert(t,c) end)
Thanksdusoft wrote: ↑Fri Dec 08, 2023 4:09 pm Iterate over the length string and extract substring for each position that you insert into a table.
Or:(https://stackoverflow.com/questions/204 ... g-to-table)Code: Select all
str:gsub(".",function(c) table.insert(t,c) end)
BTW, Stackoverflow is better place to search for generic lua answers.
Code: Select all
astring = "pog"
print(astring)
--pog
Good point.BrotSagtMist wrote: ↑Fri Dec 08, 2023 4:14 pm You probably want to use utf8.charpattern instead "." to have it catch the ö in löve.
Users browsing this forum: Bing [Bot] and 6 guests