In search of a Regexpert ...

0 views
Skip to first unread message

meino....@gmx.de

unread,
Nov 8, 2009, 8:12:58 AM11/8/09
to vim...@googlegroups.com

Hi,

I am currently trying to reformat a xml-like text to
a <tab> separated text, which I can import into gnumeric
as a cvs-file.

The original text (after some tweaking by me) looks like

<tag_1>text_1</tag_1>
<tag_2>text_2</tag_2>
<tag_3>text_3</tag_3>
<tag_4>text_4</tag_4>
<tag_5>text_5</tag_5>

in which 'tag_<n>' is any text for a tag and 'text_<n>' is any
kind of text (but without any '<' or '>' included.
After some editing I got this from the above text:

tag_1>text_1</tag_1>
tag_2>text_2</tag_2>
tag_3>text_3</tag_3>
tag_4>text_4</tag_4>
tag_5>text_5</tag_5>

and currently I cannot manage to remove the

'tag_<n>>' from the beginning of each line. Unfortunately
the tags are of different lengths so a simple visual block
deletion does not work here. I tried:


:'<,'>s/^[^\>]\+>//g

with the text in a visual block but it states to not to
find the regexp'ed text.

I know, I am doing some wrong magic here, and I doubt whether
it is magic at all...but may be there is some wizard out
there who likes to show me the trick ?!?

Thanks a lot in advance!

Have a nice Sunday!
Best regards,
mcc


--
Please don't send me any Word- or Powerpoint-Attachments
unless it's absolutely neccessary. - Send simply Text.
See http://www.gnu.org/philosophy/no-word-attachments.html
In a world without fences and walls nobody needs gates and windows.

Christian Brabandt

unread,
Nov 8, 2009, 8:21:00 AM11/8/09
to vim...@googlegroups.com
Hi meino.cramer!

On So, 08 Nov 2009, meino....@gmx.de wrote:

> tag_1>text_1</tag_1>
> tag_2>text_2</tag_2>
> tag_3>text_3</tag_3>
> tag_4>text_4</tag_4>
> tag_5>text_5</tag_5>
>
> and currently I cannot manage to remove the
>
> 'tag_<n>>' from the beginning of each line. Unfortunately
> the tags are of different lengths so a simple visual block
> deletion does not work here. I tried:
>
>
> :'<,'>s/^[^\>]\+>//g

This works for me on your sample text, you have given above. You can
also try to use a non-greedy expression:

s/^.\{-\}>//g

Which should delete everything from line start to the first closing
bracket >

> with the text in a visual block but it states to not to
> find the regexp'ed text.

Alternatively, you can visually select the first column, search for >
and then press d to delete the visual selected range.


regards,
Christian
--
• "Regression testing"? What's that? If it compiles, it is good, if it boots
up it is perfect.
Torvalds, Linus (1998-04-08).

meino....@gmx.de

unread,
Nov 8, 2009, 9:04:28 AM11/8/09
to vim...@googlegroups.com
Hi christian.brabandt

...thanks for the inspirations...now it works

Regards,
mcc



Christian Brabandt <cbl...@256bit.org> [09-11-08 14:24]:
Reply all
Reply to author
Forward
0 new messages