[ale] VI vs perl RE question
Joe Knapka
jknapka at kneuro.net
Wed Feb 1 11:12:10 EST 2006
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".)
/".*"
should work. But you probably really mean
/"[^"]*"
That is, a quote, possibly followed by non-quote stuff, followed by
another quote.
If you want to do the grouping you need to escape the parens (but not the
brackets, which is weird IMO):
/"\([^"]*\)"
If you're doing it in a :s/// command, remember to specify which lines
you want
to search; eg
:%s/"\([^"]*\)"/\1/gc
to replace "X" with X throughout the document.
-- JK
More information about the Ale
mailing list