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.
>
|