[Cascavel-pm] Quando *não* usar Perl?

Luis Motta Campos luismottacampos em yahoo.co.uk
Segunda Janeiro 29 23:24:17 PST 2007


On Jan 29, 2007, at 5:12 PM, Igor Sutton wrote:

>>         Qual a diferença de (.*?) para (.*) nessa expressão regular?
>
> De perldoc perlre:
>
>        By default, a quantified subpattern is "greedy", that is, it
> will match as many times as possible (given a particular starting
> location) while still allowing the rest
>        of the pattern to match.  If you want it to match the minimum
> number of times possible, follow the quantifier with a "?".  Note that
> the meanings don't change, just
>        the "greediness":
>
> Então, se você quer combinar o mínimo de vezes possíveis um padrão,
> você utiliza ?.

   Atenção!
   Não é "o mínimo de vezes possíveis", mas "o mínimo de vezes  
possíveis *ainda* *permitindo* *que* *o* *resto* *do* */pattern/*  
*coincida*". Esta diferença sutil é importante.

--
Luis Motta Campos is software engineer,
perl fanatic evangelist, and amateur {cook, photographer}




Mais detalhes sobre a lista de discussão Cascavel-pm