You forgot to specify that the Regex operation (specifically, the .
operator) should match all characters (not all characters except \n):
System.Text.RegularExpressions.Regex.Replace(s, "<test>.*<test>", string.Empty, RegexOptions.Singleline);
All you needed to add was RegexOptions.Singleline
.