Vim and regular expressions (was Re: [techtalk] Any good HTML editors for Linux?)
vdf at juno.com
vdf at juno.com
Thu Apr 5 23:54:15 EST 2001
> > On Tue, Apr 03, 2001 at 12:24:13PM -0700, jennyw wrote:
> > > I always thought vim was just another vi with a few extras. I
> guess it's got
> > > more than a few extras ... I'm installing it now. It'll be nice
> to try
> > > something familiar ...
> > >
> > > Jen
> >
> > Some of the features include syntax highlighting, support for the
> arrow
> > keys whilst in edit mode, and straight from vi, regular
> expressions.
> >
> > In terms of HTML though, where you nearly always want non-greedy
> > matches, can someone remind me how I do this. Web searches
> invariably
> > turn up "and you can use regular expression in vim, perl and blah.
> You
> > may want non-greedy expressions, in which case, try blah in Perl!"
> and
> > -perl will turn up the same page with perl5, and so on.
An example from "A Practical Guide to the UNIX System" (by Mark G. Sobel)
suggests using
/([^)]*)/
to match the shortest string enclosed within parentheses. It means,
"Find a left parenthesis, followed by 0 or more things that are NOT a
right parenthesis, followed by a right parenthesis."
The expression
/(.*)/
would find the longest string of 0 or more characters enclosed within
parentheses.
So the trick would be to construct the correct expression using the
beginning and ending characters or strings...
HTH,
Valerie
________________________________________________________________
GET INTERNET ACCESS FROM JUNO!
Juno offers FREE or PREMIUM Internet access for less!
Join Juno today! For your FREE software, visit:
http://dl.www.juno.com/get/tagj.
More information about the Techtalk
mailing list