Re: [pcre-dev] \K in lookahead assertion gives unpredictable…

Top Page
Delete this message
Author: ph10
Date:  
To: Zoltán Herczeg
CC: Pcre-dev, ND
Subject: Re: [pcre-dev] \K in lookahead assertion gives unpredictable result
On Thu, 26 Dec 2013, Zoltán Herczeg wrote:

> I didn't know it is accidental. I thought printing an empty string is
> less useful for a testing tool. Perhaps printing the offsets
> themselves would be the best.


I have committed a patch that does this:

/(?=ab\K)/+
    abcd
Start of matched string is beyond its end - displaying from end to start.
 0: ab
 0+ abcd


Note that the /+ modifier still causes the rest of the string (following
the "end" of the match) to be printed. This is in fact compatible with
Perl (the $' variable), though Perl documents the use of \K in
assertions as "not well defined".

Philip

--
Philip Hazel