Afficher un message
Vieux 05/09/2007, 10h15   #5
Rakesh Sharma
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Replace multiple occurrences of a word with a single one

The reason this does not work with /bin/sed is that that version of
'sed' doesn't support
a multi-atom RE followed by \{m,n\} . The GNU version of 'sed' can
handle that though.

In order to do it with the /bin/sed version you would have to iterate,
for example:

echo '.....' |
sed -e '
:a
s/\(Comment:\)\1/\1/
ta
'



On Sep 4, 7:06 pm, Sashi <small...@gmail.com> wrote:
> I have a line as follows:
>
> .*Comment:Comment:Comment:.* where the .* is text that is irrelevant
> to this post.
>
> I want to replace the multiple occurrences of "Comment:" with a single
> "Comment:".
>
> I can't do it within Vim 7.0. Apparently the quantifiers apply to
> repetitions of characters and not words.
> So :%s/Comment:\{2,}/Comment:/ doesn't work in Vim.
>


  Réponse avec citation
 
Page generated in 0,07570 seconds with 9 queries