fork download
  1. using System;
  2. using System.Linq;
  3. using System.Text.RegularExpressions;
  4. using System.Collections.Generic;
  5. public class Test
  6. {
  7. public static void Main()
  8. {
  9. var text = "User:George;Color:Blue;Time:100;Day:Saturday;";
  10. var dct = Regex.Matches(text, @"([^:;]+):([^;]+)")
  11. .Cast<Match>()
  12. .ToDictionary(p => p.Groups[1].Value, p => p.Groups[2].Value);
  13. var user = dct["User"];
  14. var color = dct["Color"];
  15. var time = dct["Time"];
  16. var day = dct["Day"];
  17. Console.WriteLine(user);
  18. Console.WriteLine(color);
  19. Console.WriteLine(time);
  20. Console.WriteLine(day);
  21. }
  22. }
Success #stdin #stdout 0.12s 24704KB
stdin
Standard input is empty
stdout
George
Blue
100
Saturday