如何从字符串中删除转义序列? [英] How do I remove escape sequences from my string?

查看:117
本文介绍了如何从字符串中删除转义序列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从我的字符串中删除转义序列C#:



\ OEISO0160000500800822000000000000004000000000000000408150522100522001 \ u0001 \ a



我想删除这些转义序列:

\ 0E

\ u0001

\\ \\ a



我想得到这样的字符串:



ISO0160000500800822000000000000004000000000000000408150522100522001



我尝试过:



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("\"","");

推荐答案

您需要手动完成并识别每种情况下的序列。在您的字符串中,您有三个不同格式的转义序列。因此,您的代码需要检查每个代码以确定要删除反斜杠后的字符数。
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.


这篇关于如何从字符串中删除转义序列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆