[ale] VI vs perl RE question
Joe Knapka
jknapka at kneuro.net
Wed Feb 1 17:07:29 EST 2006
Geoffrey wrote:
>Joe Knapka wrote:
>
>
>>Jim wrote:
>>
>>
>>
>>
>>>I'm trying to use vi to search for something enclosed in quotes, using
>>>perl RE I get a hit with $var =~/"(.*?)"/; But using the same re in vi
>>>
>>>
>>>
>>>
>>So this is, "a quote, possibly followed by something, followed by
>>another quote".
>>(The question mark is redundant, since * already means "0 or more
>>occurrences".)
>>
>>
>
>I would expect that the ? says 'at least one character.'
>
>
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.
-- Joe
More information about the Ale
mailing list