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?
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!