using System.Text.RegularExpressions;
public static void Main()
Console.WriteLine("Sample 1");
Console.WriteLine(Input1);
Console.WriteLine(FilterString(Input1,"<!--","-->"));
Console.WriteLine("Sample 2");
Console.WriteLine(Input2);
Console.WriteLine(FilterString(Input2,"<!--","-->"));
Console.WriteLine("Sample 3");
Console.WriteLine(Input3);
Console.WriteLine(FilterString(Input3,"<!--","-->"));
public static string Input1=>@"packages <!--and web page<!-- asdasasdas--> editors now use--> Lorem";
public static string Input2=>@"It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as op<!--posed to using--> 'Content here, content here', making it look like readable English. Many desktop publishing packages <!--and web page<!-- asdasasdas--> editors now use--> Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).";
public static string Input3=>$"packages <!--and web {Environment.NewLine}page<!-- asdasasdas--> editors now use--> Lorem";
static string FilterString(string source, string beginPattern, string endPattern)
Regex regex = new Regex($"\\{beginPattern}.*\\{endPattern}",RegexOptions.Singleline);
return regex.Replace(source, string.Empty);