我有一个巨大的字符串,下面给出了几行:
\ x5b \ x5b \ x5b \ x220B_to5Zwh_yJXV2FKdHV2N1lndk0 \ X22,\ x5b \ x220APto5Zwh_yJXUk9PVA \ X22 \ X5D \ N,\ x22OfferArcade \ X22,\ x22application / vnd.google-apps.folder \ x22,0,0,0,0 ,1,1420447667416,1420447667294,1420447667294,1502262110474,null,\ x5b \ x5b1,\ x2204490703266643460813 \ x22,\ x22Priyam Paul \ x22,null,\ x22 // lh4.googleusercontent.com / -FE82xOkpzWw / AAAAAAAAAAI / AAAAAAAAAd8 / KPtKNTPPaNE / photo.jpg \ X22
我正在寻找一种解决方案,它可以自动检测ascii并将其转换为原始字符。
例如,ascii \x5b
实际上是[
所以我需要一个能够自动检测所有ascii并将其转换为原始字符的解决方案。
答案 0 :(得分:5)
您可以使用Regex.Unescape
//using System.Text.RegularExpressions;
string text = "\x5b\x5b\x5b\x220B_to5Zwh_yJXV2FKdHV2N1lndk0\x22"; //and so on
string decoded = Regex.Unescape(text);
Console.WriteLine(decoded);
<强>输出:强>
[[["0B_to5Zwh_yJXV2FKdHV2N1lndk0"