[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: string.findpairs?
- From: Dirk Laurie <dirk.laurie@...>
- Date: Fri, 12 Dec 2014 17:43:08 +0200
2014-12-12 15:49 GMT+02:00 Thiago L. <fakedme@gmail.com>:
> (I find it more intuitive than `for from, match1, match2, to`)
function tweak(f)
return function()
local a,b,c,d = f()
if d then return a,d-1,b,c end
end
end
S="The quick brown fox jumps over the lazy dog"
pat="()(%S+)%s+(%S+)()"
for from,to,match1,match2 in tweak(S:gmatch(pat)) do
print(from, to, match1, match2)
end