Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要删除字符串中出现的所有转义字符。
例子:
string str = "\n \b \t \r Hello \n \b \t \r";
预期输出:您好。
注意:输入中的转义字符很少。我需要在输入中找到转义字符时删除它。
我试过了Regex.Unescape(str)。但我没有解决这个问题。
Regex.Unescape(str)
提前致谢。
你需要更换这个
"\\[bntr]"
在您的输入字符串中到处都有一个空字符串,除非有其他限制,否则您应该没问题 - 在这种情况下,请告诉我。 您可能还想在之后替换额外的空格。
你可以试试白名单正则表达式
^[\b \t \n \r]*$