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

Igor Sutton igor.sutton em gmail.com
Segunda Janeiro 29 08:12:12 PST 2007


>         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 ?.

-- 
Igor Sutton Lopes <igor.sutton em gmail.com>


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