fork(2) download
  1. using System;
  2. using System.Linq;
  3. using System.IO;
  4. using System.Text.RegularExpressions;
  5.  
  6. public class Test
  7. {
  8. public static void Main()
  9. {
  10. var content="heading1: contents with respect to heading1 heading2: heading2 contents heading3: heading 3 related contents sample strings";
  11. var delimiters = new string[] {"heading1:","heading2:","heading3:"};
  12. Console.WriteLine(
  13. string.Join("\n",
  14. Regex.Split(content, $@"(?={string.Join("|", delimiters.Select(m => Regex.Escape(m)))})")
  15. .Where(x => !string.IsNullOrEmpty(x))
  16. )
  17. );
  18. }
  19. }
Success #stdin #stdout 0.04s 134784KB
stdin
Standard input is empty
stdout
heading1: contents with respect to heading1 
heading2: heading2 contents 
heading3: heading 3 related contents sample strings