using System;
using System.Linq;
using System.IO;
using System.Text.RegularExpressions;
public class Test
{
public static void Main()
{
var content="heading1: contents with respect to heading1 heading2: heading2 contents heading3: heading 3 related contents sample strings";
var delimiters = new string[] {"heading1:","heading2:","heading3:"};
Console.WriteLine(
string.Join("\n",
Regex.Split(content, $@"(?={string.Join("|", delimiters.Select(m => Regex.Escape(m)))})")
.Where(x => !string.IsNullOrEmpty(x))
)
);
}
}
dXNpbmcgU3lzdGVtOwp1c2luZyBTeXN0ZW0uTGlucTsKdXNpbmcgU3lzdGVtLklPOwp1c2luZyBTeXN0ZW0uVGV4dC5SZWd1bGFyRXhwcmVzc2lvbnM7CgpwdWJsaWMgY2xhc3MgVGVzdAp7CglwdWJsaWMgc3RhdGljIHZvaWQgTWFpbigpCgl7CgkJdmFyIGNvbnRlbnQ9ImhlYWRpbmcxOiBjb250ZW50cyB3aXRoIHJlc3BlY3QgdG8gaGVhZGluZzEgaGVhZGluZzI6IGhlYWRpbmcyIGNvbnRlbnRzIGhlYWRpbmczOiBoZWFkaW5nIDMgcmVsYXRlZCBjb250ZW50cyBzYW1wbGUgc3RyaW5ncyI7CgkJdmFyIGRlbGltaXRlcnMgPSBuZXcgc3RyaW5nW10geyJoZWFkaW5nMToiLCJoZWFkaW5nMjoiLCJoZWFkaW5nMzoifTsKICAgICAgICBDb25zb2xlLldyaXRlTGluZSgKICAgICAgICAJc3RyaW5nLkpvaW4oIlxuIiwgCiAgICAgICAgCQkJUmVnZXguU3BsaXQoY29udGVudCwgJEAiKD89e3N0cmluZy5Kb2luKCJ8IiwgZGVsaW1pdGVycy5TZWxlY3QobSA9PiBSZWdleC5Fc2NhcGUobSkpKX0pIikKICAgICAgICAJCQkJIC5XaGVyZSh4ID0+ICFzdHJpbmcuSXNOdWxsT3JFbXB0eSh4KSkKICAgICAgICAJCSkKICAgICAgICAJKTsKCX0KfQ==