"-> {}" is a table capture that is consuming your last capture (the 'o' in the first example, an empty capture in the second) and producing a table. Remove it and you will get the result you want.
On Fri, Jul 3, 2009 at 9:45 PM, Norbert Kiesel
<nkiesel@tbdnetworks.com> wrote:
Hi,
I started to play around a bit with lpeg and found a (for me) suprising
behavior: the following lua code
lpeg=require"lpeg"
require"re"
print("lpeg version", lpeg.version())
x = {re.find('hello', [[ { 'h' . . } { . } { . } -> {} ]])}
print(type(x), #x, x[1], x[2], x[3], x[4])
print(type(x[4]), #x[4], x[4][1])
prints
lpeg version 0.8
table 4 1 hel l table: 0x6c7710
table 1 o
I would have expected to get
lpeg version 0.8
table 4 1 hel l o
string 1 nil
why is the last capture returned as a table?
</nk>