lua-users home
lua-l archive

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

* On Thu Mar 10 15:55:02 +0100 2011, Roberto Ierusalimschy wrote:
> > As you can see the data in the "value" field is also found split up into its
> > parts in the "details" part of the table. First it is captured as a whole,
> > after which it is passed to another part of the parser that knows how to deal
> > with the particular header type and cut it in pieces.
> You may capture the same data several times without parsing twice the
> input, if you nest your captures. For instance, the following pattern
> captures both the entire expression and its two words:
>   word = lpeg.R"az"^1
>   p = lpeg.C(lpeg.C(word) * "=" * lpeg.C(word))
>   print(p:match('one=two'))  ->  one=two    one    two

Ah of course, how simple, that'll do the trick.