Using multiple character classes

Ok, I am trying to print ALL characters of a string (numbers, letters, and spaces). I am currently using the following code.

local word = "pizza2009"

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

This works, forever if I adding a space between the “p” and “i” it would not print that. It just ignores it.

So I am trying to figure out how I can get it to include printing the space.

Replace your string pattern with “[%w%s]”
%w will include all alphanumeric characters and %s will include whitespace characters

String Patterns Documentation

Thank you for your help! :smiley: @anthropomorphic_dev

Do you happen to know how I would get the last letter of the string?

Nevermind, solved it. Still thank you for your help!