It seems simple enough, right? Well, I don’t know.
Here’s the code I’m trying:
input = Regex.Replace(input, "\\", "\\\\\\");
However, I’m receiving an error,
ArgumentException was unhandled – parsing “\” – Illegal \ at end of pattern.
How do I do this?
The first one should be
"\\\\", not"\\". It works like this:"\\".\in a string.With regex, it’s much easier to use a “verbatim string”. In this case the verbatim string would be
@"\\". When using verbatim strings you only have to consider escaping for the regex engine, as backslashes are treated literally. The second string will also be@"\\", as it will not be interpreted by the regex engine.