Regex只适用于一些字符

本文关键字:字符 适用于 Regex | 更新日期: 2023-09-27 18:16:35

我有这样的文本:

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/

Regex只适用于一些字符

例如

 String str = "Text contains 'r 'n string here";
 str = str.Replace("('r'n", " "); // with blank space

您可以尝试使用replace:

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