LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
Email to...
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[ILUG] Regex Question

[ILUG] Regex Question

Michael Conry michael.conry at gmail.com
Mon Sep 27 16:19:18 IST 2004


Hi,

I'm no regex guru, but this seems to work.  You might need to fine
tune a bit (and the first but assumes you have pre-selected the text
to be re-worked using the vim visual selection

:'<,'>s/\(\%(<div[^>]\+><[^>]\+>\_s\)\{2\}<div[^>]\+>\)\([^<]*\)\(<\/div>\)/\1
TEST \3/

michael

On Mon, 27 Sep 2004 14:39:15 +0100, Rory Winston <rwinston at eircom.net> wrote:
> Regex gurus,
>
> I'm trying to do a simple substitute in Vim. I hav a HTML page with hundreds
> of lines like:
>
> <div class="foo"></div>
> <div class="foo"></div>
> <div class="foo"></div>
> <div class="foo"></div>
>
> What I would like to be able to do is replace every n'th element with
> something else. So if n = 3, then the result is:
>
> <div class="foo"></div>
> <div class="foo"></div>
> <div class="foo">TEST</div>
> <div class="foo"></div>
> <div class="foo"></div>
> <div class="foo">TEST</div>
>
> Does anybody know how I might achieve this?



More information about the ILUG mailing list
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


Maintained by the ILUG website team. The aim of Linux.ie is to support and help commercial and private users of Linux in Ireland. You can display ILUG news in your own webpages, read backend information to find out how. Networking services kindly provided by HEAnet, server kindly donated by Dell. Linux is a trademark of Linus Torvalds, used with permission. No penguins were harmed in the production or maintenance of this highly praised website. Looking for the Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!
RSS Version
Powered by Dell