Re: [pcre-dev] Partial matching in PCRE

Pàgina inicial
Delete this message
Autor: Philip Hazel
Data:  
A: ND
CC: pcre-dev
Assumpte: Re: [pcre-dev] Partial matching in PCRE
On Sun, 6 Sep 2009, ND wrote:

> segment1: abcfooba
> segment2: d
> pattern: /foobar|(<=cfoob)an|(<=abcfoob)ad/
>
> Is there correct result produced with PCRE_PARTIAL_HARD in this situation?
> What alternative works first? IMHO, the first.


Correct. (If you use pcre_exec.)

> If it is, than the main application must have another way to determine
> the length of discarded part of the current segment. May it be that a
> pcre_fullinfo return the maximum lookbehind size of compiled pattern?


I had thought of this case, and realized that it is not covered.

I do not believe that it is possible to make pcre_fullinfo do what you
want, at least not straightforwardly (and at this stage of PCRE's life,
I am not going to re-design the whole thing).

A related problem was a request to make pcre_fullinfo give the minimum
length of string needed for a match. I started writing this, but got
stuck on what to do with recursions.

The best that could be done, perhaps, would be to make available the
length of the longest lookbehind anywhere in the pattern. That would be
overkill, but it would cover all cases....no, it would just cover simple
cases. Oh dear. Lookbehinds can themselves contain lookbehinds... and of
course there is the problem of recursion again.


Philip

--
Philip Hazel