Re: [pcre-dev] several messages

Kezdőlap
Üzenet törlése
Szerző: ND
Dátum:  
Címzett: Pcre-dev
Tárgy: Re: [pcre-dev] several messages
On 2012-01-24 10:22, Philip Hazel wrote:

>PCRE could tell the application the maximum lookbehind length, but what 
> it cannot tell is whether there is a lookbehind further along the path 
> that is being matched. So I don't think it should change its result.
> However, an application can choose to treat "no match" as "partial
> match", and retain some characters from the previous segment. So I think 
> the code could be something like this:
>  IF hard partial matching AND not anchored[1] AND no match THEN
>     Retain maximum lookbehind length[2] in current segment
>     Join next segment
>     Match again, with start_offset set to point to next segment
>[1] PCRE_INFO_OPTIONS can be used to find if anchored.
> [2] PCRE_INFO_MAX_LOOKBEHIND does not exist, but it could quite easily
>     be implemented. Until it is, you could just guess a suitable number.


It looks as good idea.
I'm not sure that negative PCRE_INFO_MAX_LOOKBEHIND value will be useful.
IMHO there is no difference between zero length lookbehind and no
lookbehind. In this cases I suggest to return 0 as
PCRE_INFO_MAX_LOOKBEHIND value.