日期:2014-05-17 浏览次数:20428 次
[cms:property name="username1" type="string" ishidden="false"][/cms:property]sdfsdfkkkklll[cms:property name="username2" type="string" ishidden="false"][/cms:property]klkjsldkjflskjfdljalskfj[cms:property name="username3" type="string" ishidden="false"][/cms:property]
string str = @"[cms:property name=""username1"" type=""string"" ishidden=""false""][/cms:property]sdfsdfkkkklll[cms:property name=""username2"" type=""string"" ishidden=""false""][/cms:property]klkjsldkjflskjfdljalskfj[cms:property name=""username3"" type=""string"" ishidden=""false""][/cms:property]";
//循环读取
foreach (Match m in Regex.Matches(str, @"\[(\S+)(\s*?(?<attr>[^=\[\]\s]+?=['""]?[^'""\s]+?['""])\s*?)*\]\s*?\[\/\1\]"))
{
Console.WriteLine("当前标签是:"+m.Groups[1].Value);
//
string tag = m.Groups[1].Value;
//cms:property
Console.WriteLine(string.Join("
------解决方案--------------------
",m.Groups["attr"].Captures.Cast<Capture>().Select(a=>a.Value)));
List<string> list = m.Groups["attr"].Captures.Cast<Capture>().Select(a => a.Value).ToList();
/*
* [0] "name=\"username1\"" string
[1] "type=\"string\"" string
[2] "ishidden=\"false\"" string
&