How to iterate individual characters in Lua string?
snippet in lua

How to iterate individual characters in Lua string?

user377

for i = 1, string.len(str) do
    print( string.sub(str, i, i) )
end

How to iterate individual characters in Lua string?

user1282

local str = "ab/cd/ef"
local target = string.byte("/")
for idx = 1, #str do
   if str:byte(idx) == target then
      print("Target found at:", idx)
   end
end