using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text.RegularExpressions; public class Test { public static void Main() { var text = "attr one = one two three attr two = 3"; var dct = Regex.Matches(text, @"\battr\s+(?\S*)\s+=\s+(?.*?)(?=\s+attr\s|\z)") .Cast() .ToDictionary(p => p.Groups["name"].Value, p => p.Groups["value"].Value); foreach (var kvp in dct) Console.WriteLine("{0} -> {1}", kvp.Key, kvp.Value); } }