Getting every single character from a string

I am kinda confused, this is a simple question I guess, but how am I supposed to get every single character from a string using string.split()?

You can simply just do:

local chars = string.split('hello', '')
--{'h', 'e', 'l', 'l', 'o'}
2 Likes

hm that’s weird, i tried that but did not seem to work? let me try again just to make sure…

Try this:

local word = "pizza"

for w in string.gmatch(word, "(%w)") do
      print(w)
end
1 Like