fork(2) download
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. var text = @"
  9. <live key>test</live key>
  10. <not live>test</not live>
  11. <Test>hello</Test>
  12. ";
  13. Regex rx = new Regex("<([^>\n]*)>(.*?)</(\\1)>");
  14. var m = rx.Match(text);
  15. while (m.Success) {
  16. Console.WriteLine("{0}='{1}'", m.Groups[1], m.Groups[2]);
  17. m = m.NextMatch();
  18. }
  19. }
  20. }
Success #stdin #stdout 0.09s 34096KB
stdin
Standard input is empty
stdout
live key='test'
not live='test'
Test='hello'