[ale] VI vs perl RE question
Geoffrey
esoteric at 3times25.net
Wed Feb 1 20:11:59 EST 2006
Joe Knapka wrote:
> 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.
To add to the confusion, I was thinking of shell re, that is:
ls .??*
will list all files that begin with a dot, have at least two characters
following the dot, as in:
.zsh
.ksh
But not:
.e
Sorry for the posting before engaging brain...
--
Until later, Geoffrey
More information about the Ale
mailing list