I have a string which has several occurrences of the following text, exactly as it appears:
\\(Y/A M D/J\\
The unclosed parenthesis is causing issues, so I thought I would remove the offending section, as I do not need that portion for my use of the larger string.
I've attempted to use the following line to remove the text, however Line
is identical before and after running:
Line = Line.Replace(@"\\(Y/A M D/J\\", "");
I've used the verbatim string Identifier to avoid confusion with having to escape the special characters manually. Is there something special required to do a string.replace() when working with verbatim strings?
Note: The string Values I'm getting are pulled from Visual Studio's quickwatch feature, where I am inspecting Line
and copying the value.
Are you sure that the
\\
in the original string does not include escape characters? The following snippet works as you desire but assumes the original value,input
, is exactly as shown. The result isoutput
will containsome more text
:Link to .NET Fiddle to demonstrate