fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text.RegularExpressions;
  5.  
  6. namespace ConsoleApplication3
  7. {
  8. class Program
  9. {
  10. public static void Main(string[] args)
  11. {
  12. var str = @"1-1 This is my first string.
  13. 1-2 This is my second string.
  14. 1-3 This is my third string.";
  15.  
  16. {
  17. IEnumerable<string> lines = Regex.Split(str, "(?:^|[\r\n]+)[0-9-]+ ").Skip(1);
  18.  
  19. foreach (var s in lines)
  20. {
  21. Console.WriteLine(s);
  22. }
  23. }
  24.  
  25. Console.WriteLine();
  26.  
  27. {
  28. Regex regex = new Regex("^(?:[0-9]+-[0-9]+ )(.*?)$", RegexOptions.Multiline);
  29.  
  30. var matches = regex.Matches(str);
  31.  
  32. IEnumerable<string> lines = matches.Cast<Match>().Select(p => p.Groups[1].Value);
  33.  
  34. foreach (var s in lines)
  35. {
  36. Console.WriteLine(s);
  37. }
  38. }
  39. }
  40. }
  41. }
  42.  
Success #stdin #stdout 0.06s 37496KB
stdin
Standard input is empty
stdout
This is my first string.
This is my second string.
This is my third string.

This is my first string.
This is my second string.
This is my third string.