fork download
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. string text = @"--------------------------------- Original Message----------------------------
  9. Some Text
  10. Some Text
  11. Some Text
  12. Some Text
  13.  
  14. --------------------------------- Original Message----------------------------
  15. Some Other Text
  16. Some Other Text
  17. Some Other Text
  18. Some Other Text";
  19. Regex rgx = new Regex(@"^[-]*[ ]*Original[ ]{1}Message[ ]*[-]*[\r\n]*[a-zA-Z\r\n ]*", RegexOptions.Multiline);
  20. int count = 0;
  21. MatchCollection matches = rgx.Matches(text);//Capture all matches in current text file.
  22.  
  23. foreach (Match match in matches)//Iterate through each match in Collection.
  24. {
  25. count++;
  26. Console.WriteLine("Match {0} {1}",count,match.Value);
  27. }
  28. }
  29. }
Success #stdin #stdout 0.07s 34080KB
stdin
Standard input is empty
stdout
Match 1 --------------------------------- Original Message----------------------------
Some Text
Some Text
Some Text
Some Text


Match 2 --------------------------------- Original Message----------------------------
Some Other Text
Some Other Text
Some Other Text
Some Other Text