[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: LPeg and function capture
- From: Philippe Lhoste <PhiLho@...>
- Date: Sun, 20 May 2012 10:09:03 +0200
Posting in the same thread, as it is related to my experiments.
I am puzzled by a result I got.
This works as expected:
local cap = m.R'AZ'
local findCap = (1 - cap) + m.C(cap)
local toMatch = "Stairway To Heaven"
local patt = findCap^0 / function (a, b, c)
return string.lower(a .. b .. c)
end
print(m.match(patt, toMatch))
But the following doesn't, the function gets all chars, not only the
capital ones (those supposed to be captured):
local patt = (findCap / function (a) return string.lower(a) end)^0
print(m.match(patt, toMatch))
Why the behavior of the pattern is changed by the associated function?
--
Philippe Lhoste
-- (near) Paris -- France
-- http://Phi.Lho.free.fr
-- http://PhiLho.deviantART.com
-- -- -- -- -- -- -- -- -- -- -- -- -- --