tests/pass/gmatch.lua

1
local i = 1;
2
local s = "the rain in spain stays mainly in the plain";
3
local st = { "the", "rain", "in", "spain", "stays", "mainly", "in", "the", "plain" };
4
for word in string.gmatch(s, "%a+") do
5
	print(word)
6
	assert(word == st[i], word.." == "..st[i]);
7
	i = i + 1;
8
end
9
 
10
assert(i == 10, i.." == 10");