[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: lpeg.U ?
- From: Albert Chan <albertmcchan@...>
- Date: Fri, 26 Jan 2018 09:21:27 -0500
> On Jan 26, 2018, at 2:14 AM, Dirk Laurie <firstname.lastname@example.org> wrote:
> 2018-01-26 0:19 GMT+02:00 albertmcchan <email@example.com>:
>> Is there a lpeg.U(n) (for undo n characters) or something similar ?
> You have two options.
> #p matches what p matches, but consumes no input.
> A Cg/Cb allows you to store a capture and use it later.
> Actually, all the answers I could give to questions like yours are in my
> lpeg-brief article on https://github.com/dlaurie/lua-notes.
Thank you, Dirk !
The official lpeg documentation is much too terse.
I like the Cg/Cb surname example, which is similar to perl back reference.
I had guessed that undo is impossible, since lpeg matching is possessive.
I was just checking if anyone did a patch for lpeg.U (or similar)
= re.match('hi', '.?..') -- actually match 3+ characters