我有这样的文字:
33113 1;3;\"windlight \"\"Feeling\"\"\r\nmetal, handmade\r\ninside: gold
metallic\r\noutisde: anthracite brushed\r\nH. 14 cm - B. 11,5
cm\";7,95;4001250331131;218,625;262,35;579;21;0004;0001;KUS\r\n
这个正则表达式:
;\\"[^;]*\\";
结果如下:
;\"windlight \"\"Feeling\"\"\r\nmetal, handmade\r\ninside: gold metallic\r\noutisde: anthracite brushed\r\nH. 14 cm - B. 11,5 cm\";
我想删除换行符\r\n
。请问您有什么想法吗?
我需要这样的东西:
var replaced = Regex.Replace(
"a regex pattern which removes \r\n from the selected text", " ");
这是我要从文本中删除的内容: http://postimg.org/image/5hbtd1czx/
答案 0 :(得分:0)
您可以尝试使用替换:
myString = text.Replace("\r\n", "")
修改强>
myString = text.Replace(System.Environment.NewLine, " ")
或
myString = text.Replace("\r\n", " ").Replace("\r", " ").Replace("\n", " ");
另请注意
string[] myString = File.ReadAllLines(yourTextFile);
这将自动删除文本中的所有\ n和\ r \ n。
答案 1 :(得分:0)
例如,
String str = "Text contains \r \n string here";
str = str.Replace("(\r\n", " "); // with blank space