I need to replace &with \&when &it is not at the end of the line and is not preceded by it \. I can successfully find &when it is not preceded \, but I cannot exclude those that are at the end of the line.
&
\&
\
line 1 & line 2 line 3 another & line 4 & is at the middle
In four lines, I want to replace &with \&in line 4.
How can i do this?
Here is what I can do so far:
/\(\\\)\@<!&
Find &if it is not preceded by \. By adding a negative lookahead \@!$that uses:
\@!$
/\(\\\)\@<!&\@!$
I should get those &that are not at the end of the line, but I cannot.
- ?
:%s/\(.\|^\)&\(.\)/\1\\\&\2/g
, &, , .
, , , , \@! . ( ), , (. :help /\@!).
\@!
:help /\@!
,
:%s/\\\@<!&\_$\@!/\\\&/g
\_$ $ one, \|, \) \n (. :help /$ :help /\_$).
\_$
$
\|
\)
\n
:help /$
:help /\_$
. , , :
:%s/\\\@<!&./\\&/g
, &, \& string, , (. :help s/\&).
:help s/\&
Source: https://habr.com/ru/post/1772708/More articles:Same origin policy for jQuery vs Browser (with OData) - javascriptHow can I programmatically change KeyView ListView in my collection? - .netHow to eliminate "www". at the beginning of the urls on the server? - urlHow to call back button from Flex application with deep binding - flexудалить 'WWW' в ASP.NET MVC 1.0 - urlAsp.net mvc models without databases / structure - asp.net-mvcHow to create a system for an editorial team - djangoCustom horizontal progress bar - androidPython 3 input variables - pythonConvert 1D list to 3D list - wolfram-mathematicaAll Articles