[ale] VI vs perl RE question
Joe Knapka
jknapka at kneuro.net
Wed Feb 1 22:30:54 EST 2006
attriel wrote:
>>In vi and [e]grep, "?" means "the preceding expression may or may not be
>>
>>
>present". It
>
>
>>Perl, it apparently means "don't be greedy", though it really surprises
>>
>>
>me that such a
>
>
>>fundamental piece of RE syntax would be different in Perl. So the ? in
>>
>>
>the original
>
>
>>(Perl) RE was not redundant; it accomplishes what [^"]* does in the
>>
>>
>non-Perl case:
>
>
>>stopping at the next quote encountered.
>>
>>
>
>Actually
>
>([a-z]+)? means some number of lowercase letters. Maybe.
>([a-z]+?)fred means lowercase letters up to the first occurrence of "fred"
>([a-z]+)fred looks for lowercase followed by fred, but not necessarily the
>first fred.
>
>
Does + mean the same thing it does in grep/vi? That is, "one or more
of the preceding expression"? If so, it appears "?" can mean
different things depending on how it's used: in the first example, above,
it seems to mean "the previous thing is optional", whereas in
the second example, it seems to mean "don't be greedy".
?
-- JK
More information about the Ale
mailing list