我怎样才能反向转义和Reescape字符串在.net中? [英] How can I Unescape and Reescape strings in .net?
问题描述
我需要一个WPF控件的文本框,可以采取文字像提交\ r \ñ\ r
(这是.NET字符串 提交\\ \\řñ\\ R
),并将其转换回提交\ r \ñ\ r
作为。净字符串。我希望的是string.Unescape()和string.Escape()方法对,但它似乎并不存在。我是不是有写我自己?或者是有一个更简单的方法来做到这一点?
System.Text.RegularEx pressions.Regex.Unescape(@\ r \ñ\ t \ t \ t \ t \ t \ t \ t \ t \ tHello的世界!)
<一个href="http://msdn.microsoft.com/en-us/library/system.text.regularex$p$pssions.regex.unescape.aspx">Regex.Unescape方法文档
I need a TextBox on a WPF control that can take in text like Commit\r\n\r
(which is the .net string "Commit\\r\\n\\r"
) and convert it back to "Commit\r\n\r"
as a .net string. I was hoping for a string.Unescape() and string.Escape() method pair, but it doesn't seem to exist. Am I going to have to write my own? or is there a more simple way to do this?
System.Text.RegularExpressions.Regex.Unescape(@"\r\n\t\t\t\t\t\t\t\t\tHello world!")
Regex.Unescape method documentation
这篇关于我怎样才能反向转义和Reescape字符串在.net中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!