[Date Prev][Date Next][Thread Prev][Thread Next]
- 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)
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
Why the behavior of the pattern is changed by the associated function?
-- (near) Paris -- France
-- -- -- -- -- -- -- -- -- -- -- -- -- --