Click here to Skip to main content
15,890,973 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to remove escape sequences from my string C#:

"\0EISO0160000500800822000000000000004000000000000000408150522100522001\u0001\a"

I want to delete these escape sequences:
"\0E"
"\u0001"
"\a"

I want to get my string of this way:

"ISO0160000500800822000000000000004000000000000000408150522100522001"

What I have tried:

String unescapedString = Regex.Unescape(textString);

string x = x.Replace("\"","");
Posted
Updated 12-Apr-19 6:52am
Comments
[no name] 12-Apr-19 13:22pm    
Most probably too pragmatic:

static void Main(string[] args)
{
string input = @"\0EISO0160000500800822000000000000004000000000000000408150522100522001\u0001\a";
string deescaped=
input
.Replace(@"\0E", "")
.Replace(@"\u0001", "")
.Replace(@"\a", "");
Console.WriteLine("Input: " + input);
Console.WriteLine("Deescaped: " + deescaped);
Console.ReadKey();
}

1 solution

You will need to do it manually and identify the sequence in each case. In your string you have three escape sequences that are all in different formats. So your code will need to examine each to identify how many characters following the backslash to remove.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900