Ответ на сообщение «Re: "\n" matches both '[\n]' and '[^\n]'», присланное в 03:12:36 21 июня 2010, Понедельник, отправитель Tony Mechelynck:
I found a way to match <!NL> with [^\x0a], but this makes pattern less
readable,
your suggestion is even worse.
Текст сообщения:
> On 20/06/10 21:49, ZyX wrote:
> > While trying to purge comment lines inside a variable, I encountered the
> >
> > following problem:
> > :echo substitute("a\nb", '[\n]', '<NL>', 'g')
> >
> > a<NL>b
> >
> > :echo substitute("a\nb", '[^\n]', '<!NL>', 'g')
> >
> > <!NL><!NL><!NL>
> >
> > app-editors/vim-7.2.303 (Gentoo amd64),
> > not fixed in
> > app-editors/vim-7.2.442 (Gentoo ~amd64)
>
> I also see this (which, from the help paragraph mentioned by John, might
> be intentional) in Vim 7.3a. However, after some experimenting, I found
>
> how not to match a linefeed:
> :echo substitute("a\nb", '[^\d0]', '<!NL>', 'g')
>
> <!NL>
> <!NL>
>
> see :help NL-used-for-Nul
>
>
> Best regards,
> Tony.
>
signature.asc
Description: This is a digitally signed message part.
