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

Kezdőlap
Üzenet törlése
Szerző: Philip Hazel
Dátum:  
Címzett: Sheri
CC: pcre-dev
Tárgy: Re: [pcre-dev] Ungreedy quantification in atomic groups
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

--
Philip Hazel, University of Cambridge Computing Service.