public void rev() { string img = ""; string text = ""; splitImgAndText("<font style="color:red" mce_style="color:red">测试</font><img src="title.jpg" mce_src="title.jpg" /><font style="color:red" mce_style="color:red">测试1</font>", out img, out text); } /// <summary> /// 把图文分解成图,文 /// </summary> /// <param name="html">输入HTML</param> /// <param name="img">图</param> /// <param name="text">文</param> public static void splitImgAndText(string html, out string img, out string text) { if (html == null) { img = ""; text = ""; return; } Regex regex = new System.Text.RegularExpressions.Regex(@"<img[/s/S]+</img *>|<img[^>]+/? *>", System.Text.RegularExpressions.RegexOptions.IgnoreCase); Match m = regex.Match(html); string imgstr = string.Empty; while (m.Success) { imgstr += m.Value; m = m.NextMatch(); } string textStr = FilterHTML(html); img = imgstr; text = textStr; } public static string FilterHTML(string html) { if (html == null) return ""; System.Text.RegularExpressions.Regex regex1 = new System.Text.RegularExpressions.Regex(@"<[^>]*>", System.Text.RegularExpressions.RegexOptions.IgnoreCase); html = regex1.Replace(html, ""); return html; }