I have the following regex:
s/\\/\\\\/g
This does a nice job of replacing all "\
" characters with "\\
". However, I want to guard against matching backslashes that are adjacent to other backslashes. If I do this:
s/[^\\]\\[^\\]/\\\\/g
it only catches non-adjacent backslashes. But now there's the obvious problem that the matches include the two neighboring charaters that shouldn't be replaced. How can I overcome this?