110,571
社区成员
发帖
与我相关
我的任务
分享
s.Replace("\\b", "\b").Replace("\\t", "\t").Replace("\\r", "\r").Replace("\\n", "\n");
static void test()
{
string res = System.Text.RegularExpressions.Regex.Replace("a\\b\\t\\r\\n123",
"\\\\[btrn]", (System.Text.RegularExpressions.Match m)=>
{
string replaces = "\b\t\r\n";
string chars = "btrn";
int n = chars.IndexOf(m.Value[1]);
return replaces.Substring(n, 1);
});
MessageBox.Show(res);
}
void test()
{
string res = System.Text.RegularExpressions.Regex.Replace("a\\b\\t\\r\\n123",
"\\\\[btrn]", delegate(System.Text.RegularExpressions.Match m)
{
string replaces = "\b\t\r\n";
string chars = "btrn";
int n = chars.IndexOf(m.Value[1]);
return replaces.Substring(n, 1);
});
MessageBox.Show(res);
}