C# 使用正则表达式C双击输入replace with space#

C# 使用正则表达式C双击输入replace with space#,c#,regex,C#,Regex,我的情况是这样的: 1:3 And God said, Let there be light: and there was light.</p> <p>And God saw the light, that it was good: and God divided the light from the darkness. 1:3神说,要有光,就有光了 神看见光是好的,就把光与黑暗分开。 我想用C语言中的正则表达式将这两行合并成一行# 我曾经 var p = Reg

我的情况是这样的:

1:3 And God said, Let there be light: and there was light.</p>

<p>And God saw the light, that it was good: and God divided the light from the darkness.
1:3神说,要有光,就有光了

神看见光是好的,就把光与黑暗分开。
我想用C语言中的正则表达式将这两行合并成一行#

我曾经

 var p = Regex.Match(line, @”</p>\n\n<p>[A-z]“);
 if (p.Success)
 {
     MessageBox.Show(p.Value);
 }
var p=Regex.Match(第行,@“

\n\n[A-z]”); 如果(p.Success) { MessageBox.Show(p.Value); }
您需要使用
Regex.Replace

Regex.Replace(line, @"</p>\n\n<p>", " ");
Regex.Replace(第行,@“

\n\n”,“”);
然而,一种更简单的方法是:

Regex.Replace(line, @"(</?p>|\s)+", " ");
Regex.Replace(第行,@“(|\s)+”和“);

这对于文本中有多少换行符或什么类型的换行符也更为有效。

为什么需要正则表达式?您只需使用
s=s.Replace(“\n\n”,”);
不需要正则表达式。试试看

line = line.Replace("\n\n", " ");

结果是什么?出了什么问题?我想在我尝试这个表达的时候也有一些东西,但它不起作用。它找不到表达本身。这是我的经文:1:3上帝说,要有光,就有光。和