string.gmatch for Tokenization
Iterate over all matches in a string with string.gmatch.
What Is string.gmatch?
string.gmatch(s, pattern) returns an iterator that successively returns all matches of pattern in string s.
Iterating Over Words
Tokenize a string into words by matching sequences of non-space characters.
local s = "the quick brown fox"
for word in s:gmatch("%S+") do
print(word)
endAll lessons in this course
- Lua Pattern Syntax
- Captures and string.match
- string.gmatch for Tokenization
- string.gsub for Transformations