用一个换行符替换多个换行符

Moh*_*yed 3 c# regex

我想用C#中的任何数字替换\r\n一个\r\n\r\n。抱歉,这是一个愚蠢的问题,但我是regex的新手。
其实我试过了

clearstring = Regex.Replace(clearstring, @"\r\n+", "\r\n\r\n", RegexOptions.Singleline | RegexOptions.Compiled | RegexOptions.ExplicitCapture | RegexOptions.IgnoreCase);
Run Code Online (Sandbox Code Playgroud)

但是它没有用,有什么建议吗?我会很感激。

dot*_*NET 5

尝试

clearstring = Regex.Replace(clearstring, @"(\r\n)+", "\r\n\r\n", RegexOptions.Singleline | RegexOptions.Compiled | RegexOptions.ExplicitCapture | RegexOptions.IgnoreCase);
Run Code Online (Sandbox Code Playgroud)

规则是,量词(在您的情况下为加号)仅适用于紧接在前的组或字符类,在您的情况下仅为\ n。如果要包括多个字符或类,则应将它们归为一组。