Reputation: 39
So I recently used this following lua code to separate each word from string and notice it's not showing special characters (e.g. /,;,'
). So is there anyway for it to show?
string = "Test, Im testing"
for word in string:gmatch("%w+") do
print(word)
end
This code will not show the commas on the string but I need it to show.
Upvotes: 1
Views: 106
Reputation: 80657
Instead of %w
I think you are looking for %S
pattern.
Alternatively you can also try [%w%p]+
.
See a brief description of how lua pattern behave at lua pil
Upvotes: 3