using System; using System.Text.RegularExpressions; using System.Linq; public class Test { public static void Main() { var str = @"namespace MyNameSpace { [MyAttribute] public class MyClass { [MyPropertyAttribute(DefaultValue = ""Default Value 1"")] public static string MyProperty1 { get { return ""hello1""; } } [MyPropertyAttribute(DefaultValue = ""Default Value 2"")] public static string MyProperty2 { get { return ""hello2""; } } } }"; var regex = @"\[MyPropertyAttribute\(DefaultValue = ""([^""]+)""\)\]" + @"\s+public static string ([a-zA-Z0-9]+)"; var matches = Regex.Matches(str, regex); foreach (var match in matches.Cast()) { Console.WriteLine(string.Format("{{\"{0}\", \"{1}\"}}", match.Groups[2].Value, match.Groups[1].Value)); } } }