lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


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>