Delete all characters except ...

0 views
Skip to first unread message

David Fishburn

unread,
Nov 17, 2008, 11:36:35 PM11/17/08
to vim_use
I have this string:
<this/><that/>

I want to end up with this:
/>/>

This must be recursive, and there could be other things than just a word:
<this colspan="2"/><that andmore="dd"/>

I have tried a couple of combinations
substitute('<this/><that/>', '\(/>\)\?\zs.\{-}\(/>\)\?', '', 'g')

I can get the first instance, but if there are more than 1 '/>' I get messed up.

Anyone have any good suggestions?

Thanks,
Dave

Yegappan Lakshmanan

unread,
Nov 18, 2008, 12:11:19 AM11/18/08
to vim...@googlegroups.com
Hi Dave,

You can try using the following:

substitute(myvar, '.\{-}\(/>\)', '\1', 'g')

- Yegappan

Erik Hahn

unread,
Nov 18, 2008, 12:35:06 PM11/18/08
to vim...@googlegroups.com

This works when editing, I don't know how to do that in a script:
:s/[^/<]//g

-Erik

--
v4sw5RUYhw2ln3pr5ck0ma2u7Lw3+2Xm0l6/7Gi2e2t3b6AKMen5+7a16s0Sr1p-8.12/-6.56g6OR

Reply all
Reply to author
Forward
0 new messages