[Solved] how to split a text in to paragraph with a particular string


Try using RegEx.Split() using this pattern:

(.*This is common text.*)

Well, giving priority to RegEx over the string functions is always leads to a performance overhead.

It would be great if you use: (UnTested but it will give you an idea)

string[] lines = IO.File.ReadAllLines("FilePath")
List<string> lst = new List<string>();
List<string> lstgroup = new List<string>();

int i=0;
foreach(string line in lines)
{
    if(line.Tolower().contains("this is common text"))
    {
         if(i > 0)
         {
             lst.AddRange(lstgroup.ToArray());

             // Print elements here
             lstgroup.Clear();
         }
         else { i++; }
         continue;
    }
    else
    {
      lstgroup.Add(line)
    }
}
i = 0;
// Print elements here too

solved how to split a text in to paragraph with a particular string