110,499
社区成员
发帖
与我相关
我的任务
分享
string input = @"<element id=值无引号 无值属性 class=""值1 值2"" style='bg:#d; w:2; '></element>";
Dictionary<string,string> dic = new Dictionary<string,string>();
MatchCollection mc = Regex.Matches(input, @"([^\s=]+)=(['""\s]?)([^'""]+)\2(?=\s|$|>)");
foreach (Match m in mc)
{
dic.Add(m.Groups[1].Value, m.Groups[3].Value);
}
dic.ToList().ForEach(e => Response.Write(e.Key+"\t"+e.Value));//看看
string input = @"<element id=值无引号 无值属性 class=""值1 值2"" style='bg:#d; w:2; '></element>";
Dictionary<string,string> dic = new Dictionary<string,string>();
MatchCollection mc = Regex.Matches(input, @"([^\s=]+)=(['""\s]?)([^'""]+)\2(?=\s|$|>)");
foreach (Match m in mc)
{
dic.Add(m.Groups[1].Value, m.Groups[3].Value);
}
dic.ToList().ForEach(e => Console.WriteLine(e.Key+"\t"+e.Value));