[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: LPeg 0.10.2: no more captures returned by '#' predicate.
- From: Roberto Ierusalimschy <roberto@...>
- Date: Thu, 10 Mar 2011 11:55:02 -0300
> 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
-- Roberto