On Tue, 19 Feb 2002, Peter R. Wood (Lists) wrote:
> > 
> > If so, your \s+ fails. I don't use Oracle, so I can't check any of this,
> > but what about this?
> > 
> > /*+ FIRST_ROWS */ /*+ DOMAIN_INDEX_SORT */
> > 
> > If so, your .* should be .*?
> > 
> 
> .* = match a single character zero or more times, yes?
> .*? = the above condition, but only zero or one instances of the above?
> What would the .*? do for me?

In your example, "zero or more characters" could match either "FIRST_ROWS"
or "FIRST_ROWS */ /*+ DOMAIN_INDEX_SORT" while allowing the full pattern
to match.  .* will match the latter, .*? will match the former.

>From the perlre manpage:

       By default, a quantified subpattern is "greedy", that is, it will
       match as many times as possible (given a particular starting loca
       tion) 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":

           *?     Match 0 or more times
           +?     Match 1 or more times
           ??     Match 0 or 1 time

Excessively greedy quantifiers are a very common error. :)

Alan


Reply via email to