fork(1) download
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. string text = @"N:
  9. TEL:+65123345
  10. END:VCARD
  11. BEGIN:VENV
  12. BEGIN:VBODY
  13. Date:8/11/2013 11:59:00 PM
  14. thi is a test message
  15. Hello this is a test message on line 2
  16. END:VBODY
  17. END:VENV
  18. END:VENV
  19. END:VMSG";
  20.  
  21. string pattern = @"BEGIN:VBODY(?<Value>[a-zA-Z0-9\r\n.\S\s ]*)END:VBODY";//Pattern to match text.
  22. Regex rgx = new Regex(pattern, RegexOptions.Multiline);//Initialize a new Regex class with the above pattern.
  23. Match match = rgx.Match(text);//Capture any matches.
  24. if (match.Success)//If a match is found.
  25. {
  26. string value2 = match.Groups["Value"].Value;//Capture match value.
  27. Console.WriteLine(value2);
  28. }
  29. }
  30. }
Success #stdin #stdout 0.07s 34016KB
stdin
Standard input is empty
stdout
            Date:8/11/2013 11:59:00 PM
            thi is a test message
            Hello this is a test message on line 2