Verbatim string c# "'a\\\' b'"

123 Views Asked by At

I have string 'a\\\' b', i need make algorithm which will convert this string to string 'a' b'

  1. 'a\\\' b' = > 'a\\' b' => 'a\' b' = > 'a' b' How i can make it? Maybe c# have a method which can check , is char contains verbatim symbol or not?
1

There are 1 best solutions below

0
On

You could just replace the backslashes with an empty string.

string example = "'a\\\' b'";

Console.WriteLine(example.Replace("\\", string.Empty)); // Prints 'a' b'