How will I string split a pre-set string?

Hello, I am looking to basically split up the player’s name, an example of this would be:

before
evocul

after
e-v-o-c-u-l

I’ve been trying multiple different ideas for it but have yet been able to figure it out, anyone got any solutions?

you can use gmatch to iterate through the string and use string pattern “.” which represents any character, then insert each character into an array

local str = "evocul"
local chars = {}

for c in string.gmatch(str, ".") do
	table.insert(chars, c)
end

print(table.concat(chars, "-")) -- prints "e-v-o-c-u-l"

Thank you! I appreciate that heavily. I still have a lot to learn when it comes down to scripting :smile:

Also I think string.split would work too, it was added this year I believe. Didn’t test it out though so I’m not sure.

local str = "evocul"
local chars = {}

chars = string.split(str, "")
print(table.concat(chars, "-")) -- prints "e-v-o-c-u-l"

Ah, I was looking into string.split but all I found from there was just pre-set strings with a split string etc.
Thank you once again!