fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text.RegularExpressions;
  4. using System.Linq;
  5. public class Test
  6. {
  7. public static void Main()
  8. {
  9. var pat = @"(?<Attribute>\w+)=(?<Value>(?:(?!-{3})\S)+)";
  10. var s = "---MyValue=4497-DD616-1134-34---\r\n---MyNum=72 MyPercent=17% --- ";
  11. var res = Regex.Matches(s, pat)
  12. .Cast<Match>()
  13. .ToDictionary(
  14. m => m.Groups["Attribute"].Value,
  15. m => m.Groups["Value"].Value
  16. );
  17. foreach (var kvp in res)
  18. {
  19. Console.WriteLine("[{0}, {1}]", kvp.Key, kvp.Value);
  20. }
  21. }
  22. }
Success #stdin #stdout 0.03s 133824KB
stdin
Standard input is empty
stdout
[MyValue, 4497-DD616-1134-34]
[MyNum, 72]
[MyPercent, 17%]