Main Page | Report this Page
Computers Forum Index  »  Computer - Editors  »  vim regexp non-greedy search...
Page 1 of 1    

vim regexp non-greedy search...

Author Message
kurt krueckeberg...
Posted: Sun Nov 08, 2009 1:35 am
Guest
I want to change all occurances of
<FONT SIZE=3>some text goes here</FONT>
to
some text goes here</FONT>
Preferrably to just:
some text goes here

How do I compose a non-greedy regular expression to find "<FONT
SIZE=3>"? I've tried
:%s/<FONT\(.*\)\{-1}>//g

But the eliminates the entire line.

thanks.
 
Peter Gordon...
Posted: Sun Nov 08, 2009 6:16 am
Guest
kurt krueckeberg <kkruecke at (no spam) gmail.com> wrote in news:e75a9ba1-2614-480f-
9ec8-2a09aaec72a9 at (no spam) p35g2000yqh.googlegroups.com:

Quote:
FONT SIZE=3>some text goes here</FONT

If the opening & closing anchors are guaranteed to be on the

same line, the RE below will do it.

s%<FONT SIZE=3>\(.*\)</FONT>%\1%
 
Christian Brabandt...
Posted: Sun Nov 08, 2009 1:01 pm
Guest
On 2009-11-08, kurt krueckeberg <kkruecke at (no spam) gmail.com> wrote:
Quote:
I want to change all occurances of
FONT SIZE=3>some text goes here</FONT
to
some text goes here</FONT
Preferrably to just:
some text goes here

How do I compose a non-greedy regular expression to find "<FONT
SIZE=3>"? I've tried
:%s/<FONT\(.*\)\{-1}>//g

But the eliminates the entire line.

Why are you posting here and in the vim_use mailinglist?

regards,
Christian
 
Tim Roberts...
Posted: Tue Nov 10, 2009 12:22 pm
Guest
kurt krueckeberg <kkruecke at (no spam) gmail.com> wrote:

Quote:
I want to change all occurances of
FONT SIZE=3>some text goes here</FONT
to
some text goes here</FONT
Preferrably to just:
some text goes here

How do I compose a non-greedy regular expression to find "<FONT
SIZE=3>"? I've tried
:%s/<FONT\(.*\)\{-1}>//g

But the eliminates the entire line.

Think about it in words. You want <FONT followed by any number of things
that aren't >, followed by >.

:%s/<FONT[^>]*>//
--
Tim Roberts, timr at (no spam) probo.com
Providenza & Boekelheide, Inc.
 
 
Page 1 of 1    
All times are GMT
The time now is Sun Mar 21, 2010 6:13 am