Friday, April 2, 2010

Re: Search & Replace

Hi Benjamin!

On Fr, 02 Apr 2010, Benjamin R. Haskell wrote:

> On Fri, 2 Apr 2010, Christian Brabandt wrote:
>
> > Hi Kunal!
> >
> > On Fr, 02 Apr 2010, Kunal Bajpai wrote:
> >
> > > To this html code I wanted to select the text between the tags and
> > > replace the original text with \n character removed. There is a more
> > > complex example that I wanted to ask, here is the problem:
> > >
> > > Original
> > > ______________________________
> > > <p>Mike
> > > <strong>Gilbert </strong>
> > > Senior</p>
> > > _____________________________
> > >
> > > After search & replace:
> > > ______________________________
> > > <p>Mike <strong>Gilbert</strong> Senior</p>
> > > _____________________________
> > >
> > > I hope you really got what I was asking.
> >
> Good explanation, Christian.
>
> Here's one that's more general (not tailored to the specific contents of
> that '<p>' tag):
>
> :%s/<\(p\)\_[^>]*>\_.\{-}<\/\1>/\=substitute(submatch(0),"\n"," ","g")/

Good hint. I thought about that, but then I couldn't insert <strong>
tags around it anymore. But then again, this wasn't event asked for and
I thought the OP wanted the <strong> tags around the name, since these
tags were missing in his first mail. Oh Well.


regards,
Christian

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

To unsubscribe, reply using "remove me" as the subject.

No comments: