Re: [pcre-dev] Ungreedy quantification in atomic groups

Página superior
Eliminar este mensaje
Autor: Sheri
Fecha:  
A: pcre-dev
Asunto: Re: [pcre-dev] Ungreedy quantification in atomic groups
Philip Hazel wrote:
> On Tue, 1 May 2007, Sheri wrote:
>
>
>> Philip Hazel wrote:
>>
>>> (?>\\|\t|\Q.+?\E|\$(?:U|u|L|l|T|t)?\d{1,3})
>>>
>>> but that still doesn't make too much sense because \Q.+?\E matches the
>>> literal string ".+?". So where is the ungreedy qualifier?
>>>
>>> Philip
>>>
>>>
>>>
>> With the doubled backslashes, that alternate matches backslash Q and
>> everything inclusive up thru the next backslash E.
>>
>
> OK, so you really did mean something like
>
>     (?>\\\\|\\t|\\Q.+?\\E|\$(?:U|u|L|l|T|t)?\d{1,3})

>
> but presumably you did NOT mean \\$ or \\d{1,3} which were in the
> original pattern.
>
> Anyway, my comment still stands. If this is a complete regex, the
> overall atomic group achieves nothing because once it has matched,
> nothing that follows can fail. As it involved an extra level of
> grouping, it will use a few more resources.
>
> Philip
>
>


You're right, the original should have had only one backslash in front
of the dollar and the "d"

My real (unposted, long) original pattern had only one in those positions.

So far testing with pcretest, it seems to take a little less time to
compile as atomic group but a little more time to execute (at least
according to the timings returned -- I don't know why but running
pcretest with -t is making it take a very long time to get results (not
reflected in the measured times which are being stated in fractional
milliseconds). Hopefully not indicative of another problem.

Regards,
Sheri