求 <item>aaa</item><it>bbb</it> dd<form>ccc</form> 中取<>的结果  结果要求为 <item>、</item>、<it>、</it>、<form>、</form>  就是只取尖括号的内容  aaa bbb  等可能有任意字符

解决方案 »

  1.   


     string s = "<item>aaa</item><it>bbb</it> dd<form>ccc</form>";
                Regex re = new Regex(@"<[\s\S]*?>");
                MatchCollection mc = re.Matches(s);
                foreach (Match  m in mc)
                {
                    MessageBox.Show(m.Value.Trim());
                    //System.Diagnostics.Debug.Print (m.Value.Trim ());
                } 
    //输出 
    <item>
    </item>
    <it>
    </it>
    <form>
    </form>