Regular Expressions

I need help making a pattern that matches everything except spaces (and line feeds?), to iterate over every word in a string. I’m currently using %w+, but that only captures aplhanumerics, and not things like smileys.

%S+ if I remember right. Will iterate over everything that is not a space character( including everything that looks like a space character ).

%s+ returns the spaces, not the words.

Here’s what I do:

for w in string.gmatch(string, "%w+") do

Edit: Fixed:

for w in string.gmatch(string, "[^%s]+") do

No, %S returns the inverse of %s, which is everything but spaces.

Oh :slight_smile: Thanks then, will use that instead. Does capitalizing all of the %s work like that? So that %W is everything not alphanumeric?