fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Text.RegularExpressions;
  6.  
  7. public class Test
  8. {
  9. public static void Main()
  10. {
  11. var text = @"<AC:Value> SYMBOL: PDWFNA = 0; // Projektierung D-Weg Freimeldung nicht
  12. // auswerten
  13. <AC:Value> SYMBOL: PDWLE = 0; // Länge des Durchrutschweges";
  14. var matches = Regex.Matches(text, @"<\w{2}:Value> SYMBOL: (P.*)=(.*)//(.*(?:\n[\s-[\r\n]]*//.*)*)");
  15. foreach (Match m in matches)
  16. {
  17. Console.WriteLine("--- A new match ---");
  18. Console.WriteLine($"Group 1: {m.Groups[1].Value}");
  19. Console.WriteLine($"Group 2: {m.Groups[2].Value}");
  20. Console.WriteLine("Group 3: {0}",
  21. string.Join(" ",
  22. m.Groups[3].Value.Split(new[] {"//"}, StringSplitOptions.RemoveEmptyEntries)
  23. .Select(x => x.Trim())
  24. )
  25. );
  26. }
  27. }
  28. }
Success #stdin #stdout 0.08s 30896KB
stdin
Standard input is empty
stdout
--- A new match ---
Group 1: PDWFNA     
Group 2:  0;        
Group 3: Projektierung D-Weg Freimeldung nicht auswerten
--- A new match ---
Group 1: PDWLE      
Group 2:  0;        
Group 3: Länge des Durchrutschweges