Re: [pcre-dev] Partial matching in PCRE

トップ ページ
このメッセージを削除
著者: Philip Hazel
日付:  
To: ND
CC: pcre-dev
題目: 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/.

I hope this is what you want!

Philip

--
Philip Hazel