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 = "attr one = one two three attr two = 3";
  12. var dct = Regex.Matches(text, @"\battr\s+(?<name>\S*)\s+=\s+(?<value>.*?)(?=\s+attr\s|\z)")
  13. .Cast<Match>()
  14. .ToDictionary(p => p.Groups["name"].Value, p => p.Groups["value"].Value);
  15. foreach (var kvp in dct)
  16. Console.WriteLine("{0} -> {1}", kvp.Key, kvp.Value);
  17. }
  18. }
Success #stdin #stdout 0.06s 22216KB
stdin
Standard input is empty
stdout
one -> one two three
two -> 3