fork download
  1. using System;
  2. using System.Linq;
  3. using System.IO;
  4. using System.Text.RegularExpressions;
  5.  
  6. public class Test
  7. {
  8. public static void Main()
  9. {
  10. var str = "-AppCode='MyApplication' -AppVers='V-2016.0 Debug' -MachUuid='2C850880-34FD-12F3-A06B-7336B0C4BC55' -MachName='ABEZG-F05507' -Language=2055";
  11. var matches = Regex.Matches(str, @"(?<name>[\w-]+)=(?:'(?<value>[^']*)'|(?<value>\S+))")
  12. .Cast<Match>()
  13. .ToDictionary(p => p.Groups["name"].Value, p=> p.Groups["value"].Value );
  14. foreach (var p in matches) {
  15. Console.WriteLine(p.Key + ": " + p.Value);
  16. }
  17.  
  18.  
  19. }
  20. }
Success #stdin #stdout 0.12s 24768KB
stdin
Standard input is empty
stdout
-AppCode: MyApplication
-AppVers: V-2016.0 Debug
-MachUuid: 2C850880-34FD-12F3-A06B-7336B0C4BC55
-MachName: ABEZG-F05507
-Language: 2055