我有一些可怕的文本,我正在使用几个c#正则表达式进行清理。有一个让我难以理解的问题是文本中有很多'\ r \ n'字符串,实际字符不是换行符。C#如何Regex.Replace“ r n”(实际字符,而不是换行符)
我已经试过:
content = Regex.Replace(content, "\\r\\n", "");
和:
content = Regex.Replace(content, "\r\n", "");
,但他们都没有工作。最后,我不得不使用:
content = content.Replace("\\r\\n", "\r\n");
以完成项目,但不能在正则表达式中做到这一点让我烦恼。
可以帮助吗? http://stackoverflow.com/questions/1981947/how-can-i-remove-rn-from-a-string-in-c-can-i-use-a-regex – SubniC 2010-11-30 08:44:54
content.Replace(@“\ r \ n“,”\ r \ n“)是您的最佳选择。 – VVS 2010-11-30 08:46:30