string content = "{'A'='1','B'='2','C'='3','D'='4','E'='5','F'='6'}";
string pattern = @"'[a-zA-Z]*?'='[\w\d\.\-\:\s\*]*'?";
Dictionary<string, string> dict = RegexToDictionary(content, pattern);
//将JSON转换成字典
private Dictionary<string, string> RegexToDictionary(string content, string pattern)
{
var ms = Regex.Matches(content, pattern, RegexOptions.IgnoreCase);
Dictionary<string, string> dic = new Dictionary<string, string>();
if (ms.Count>0)
{
foreach (Match m in ms)
{
string s = m.Value.Replace("'", "");
string[] ss = s.Split(new char[] { '=' });
dic.Add(ss[0], ss[1]);
}
}
return dic;
}