lua-users home
lua-l archive

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


Hi!

On http://www.inf.puc-rio.br/~roberto/lpeg/ the description of lpeg.B says
"Matches patt behind the current position, consuming no input" in the
summary table.

The long description says "a pattern that matches only if the input string
at the current position is preceded by patt".

I've pondered over the contrast "behind the current position" and "the
current position is preceded by" for some time now, but it does not parse in
my head. Can someone please shed some light on this?

Additionally, I'm not sure what this "current position" is. I've found that

    lpeg.match( 2 * lpeg.B'sd', 'asdf' )

matches (and returns 3). If the "current position" is preceded by 'sd', it
must be "before the 'f'"? But the call returns 3, which is the index of the
first character after the match, and that is the 'd'!?

Regards,
Matthias