fork download
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. string line = "HELLO MYNAME IS1 = {P 111.11, O -222.22, L 333.33, L -444.44, Y 555.55}";
  9. Regex re = new Regex(@"^HELLO MYNAME ([A-Za-z0-9]+) = {([A-Z]\s[+-]?[0-9]+.[0-9]+,?\s?)+}");
  10. MatchCollection matchCollection = re.Matches(line);
  11. foreach(Match m in matchCollection)
  12. {
  13. Console.WriteLine("Match: ");
  14. Console.WriteLine(m.Groups[1].Value);
  15. foreach (Capture cap in m.Groups[2].Captures)
  16. Console.WriteLine($"No {cap.Index} Value: {cap.Value}");
  17. }
  18. }
  19. }
Success #stdin #stdout 0.06s 19604KB
stdin
Standard input is empty
stdout
Match: 
IS1
No 20 Value: P 111.11, 
No 30 Value: O -222.22, 
No 41 Value: L 333.33, 
No 51 Value: L -444.44, 
No 62 Value: Y 555.55