Szerző: Philip Hazel Dátum: Címzett: ND CC: pcre-dev Tárgy: Re: [pcre-dev] Partial matching in PCRE
On Wed, 2 Sep 2009, ND wrote:
> The first-encountered partial offset is not always equal to last bumpalong
> offset.
> In case of using '\K' the first-encountered partial offset is not useful,
> but last bumpalong offset is.
Indeed, and it is not only \K. If the pattern starts with a lookbehind
assertion, or \b or \B, you need characters *before* the last bumpalong
offset.
I took a look at the code, and it turned out to be surprisingly easy to
fix this. I have committed code that yields the first inspected
character that was used in the partial match. If your pattern is
/(<=foo)bar/ and your string is "abcfooba" the partial match yields
"fooba". The same with /foo\Kbar/.