fork download
  1. using System;
  2. using System.IO;
  3. using System.Text.RegularExpressions;
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. String s = ">>>tagA\ncontents 1\n<<<tagA\n...\n>>>tagB\ncontents 2\n<<<tagB\n...";
  9. var matches = Regex.Matches(s, @">>>(?<tagName>.+?)[\r\n]+(?s:(?<contents>.*?))<<<");
  10. foreach (Match m in matches) {
  11. Console.WriteLine(m.Groups["tagName"].Value);
  12. Console.WriteLine(m.Groups["contents"].Value);
  13. }
  14. }
  15. }
  16.  
  17.  
Success #stdin #stdout 0.04s 134592KB
stdin
Standard input is empty
stdout
tagA
contents 1

tagB
contents 2