[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: how to translate lua pattern "(.*)and(.*)" with lpeg re ?
- From: albertmcchan <albertmcchan@...>
- Date: Sat, 20 Jan 2018 19:11:11 -0500
Thanks ! We can now asset the following:
1 - P'and' == -P'and' * 1 == re.compile "! 'and' ."
--> lua pattern "(.*)and(.*)" == re.compile "{(!'and' .)*} 'and' {.*}"
On Jan 20, 2018, at 5:54 PM, Sean Conner <sean@conman.org> wrote:
> That was weird. I would expect
>
> C((P(1) - 'and')^1) * 'and' * C(P(1)^0)
>
> to map to:
>
> { ( . ! 'and' )+ } 'and' { .* }
>
> but it didn't. I went so far as to recompile LPeg with debugging so I could
> dump the parse tree.
>
lpeg re pattern: " { ( . ! 'and' )+ } 'and' { .* } "
should be translate to C( (1 * -P'and')^1) * 'and' * C(P(1)^0)
note the extra * after 1