大家好:
    我现在有个需求就是关于内容页去除word格式,
现在情况是内容页(包含word格式)存在数据库中,我现在想将word格式去掉如下:
   
<P class=MsoNormal><B style="mso-bidi-font-weight: normal"><SPAN style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">一.项目需求说明:</SPAN></B><B style="mso-bidi-font-weight: normal"><SPAN lang=EN-US style="mso-bidi-font-size: 10.5pt"><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></B></P>
<P class=a style="MARGIN: 6pt 0cm; TEXT-INDENT: 21pt; LINE-HEIGHT: 150%; mso-para-margin-top: .5gd; mso-para-margin-right: 0cm; mso-para-margin-bottom: .5gd; mso-para-margin-left: 0cm; mso-char-indent-count: 2.0"><SPAN style="FONT-SIZE: 10.5pt; LINE-HEIGHT: 150%; mso-bidi-font-size: 10.0pt; mso-hansi-font-family: 宋体">本软件系统主要应用于市南区政府以及广大的人民群众,方便公众可以随时随地查看政策法规、审批事项等最新服务信息,</SPAN><SPAN style="FONT-SIZE: 10.5pt; COLOR: black; LINE-HEIGHT: 150%; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial">更有效地缩短政府与民众间的距离</SPAN><SPAN style="FONT-SIZE: 10.5pt; LINE-HEIGHT: 150%; mso-bidi-font-size: 10.0pt; mso-hansi-font-family: 宋体">。<SPAN lang=EN-US><o:p></o:p></SPAN></SPAN></P>
<P class=a style="MARGIN: 6pt 0cm; LINE-HEIGHT: 150%; mso-para-margin-top: .5gd; mso-para-margin-right: 0cm; mso-para-margin-bottom: .5gd; mso-para-margin-left: 0cm"><B style="mso-bidi-font-weight: normal"><SPAN style="FONT-SIZE: 10.5pt; LINE-HEIGHT: 150%; mso-bidi-font-size: 10.0pt; mso-hansi-font-family: 宋体">二.技术需求说明:<SPAN lang=EN-US><o:p></o:p></SPAN></SPAN></B></P>
<P class=MsoNormal><B style="mso-bidi-font-weight: normal"><SPAN lang=EN-US style="mso-bidi-font-size: 10.5pt">2.1</SPAN></B><B style="mso-bidi-font-weight: normal"><SPAN style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">综合性能</SPAN></B><SPAN lang=EN-US style="mso-bidi-font-size: 10.5pt"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="TEXT-INDENT: 15.75pt; LINE-HEIGHT: 150%; mso-char-indent-count: 1.5"><SPAN lang=EN-US style="LINE-HEIGHT: 150%; mso-bidi-font-size: 10.5pt">1)</SPAN><SPAN style="LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">要实现</SPAN><SPAN style="COLOR: black; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-bidi-font-weight: bold; mso-bidi-font-size: 10.5pt; mso-ascii-font-family: 'verdana,ˎ̥'; mso-hansi-font-family: 'verdana,ˎ̥'; mso-bidi-font-family: Arial">用户随时随地查看最新信息</SPAN><SPAN style="LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">。</SPAN><SPAN lang=EN-US style="LINE-HEIGHT: 150%; mso-bidi-font-size: 10.5pt"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="TEXT-INDENT: 15.75pt; LINE-HEIGHT: 150%; mso-char-indent-count: 1.5"><SPAN lang=EN-US style="LINE-HEIGHT: 150%; mso-bidi-font-size: 10.5pt">2)</SPAN><SPAN style="LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">要实现手机和电脑同时访问。</SPAN><SPAN lang=EN-US style="LINE-HEIGHT: 150%; mso-bidi-font-size: 10.5pt"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="TEXT-INDENT: 15.75pt; LINE-HEIGHT: 150%; mso-char-indent-count: 1.5"><SPAN lang=EN-US style="LINE-HEIGHT: 150%; mso-bidi-font-size: 10.5pt">3)</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">要实现快速查询的功能,只要输入相关主题的关键字就能十分轻松方便地找到您想要的信息。</SPAN></P>

解决方案 »

  1.   

    替换成如下结果:
    &nbsp;&nbsp;&nbsp;
    <br>一.项目需求说明:
    <br>本软件系统主要应用于市南区政府以及广大的人民群众,方便公众可以随时随地查看政策法规、审批事项等最新服务信息,更有效地缩短政府与民众间的距离。
    <br>二.技术需求说明:
    <br>2.1综合性能
    <br>1)要实现用户随时随地查看最新信息。
    <br>2)要实现手机和电脑同时访问。
    <br>3)要实现快速查询的功能,只要输入相关主题的关键字就能十分轻松方便地找到您想要的信息。如果有table标签则保留table的样式。谢谢大家
      

  2.   

    不怎么会
    自己研究研究吧http://deerchao.net/tutorials/regex/regex.htm
      

  3.   

    一般文本输出就行了。http://hi.baidu.com/apxsoft/blog/item/3077dc11fdc461c3a7ef3fbf.htmlhttp://hi.baidu.com/apxsoft/blog/item/2e479064db646ff5f73654bf.html研究研究。
      

  4.   

    try...Regex reg = new Regex("<[^>]*>");
    string result = reg.Replace(yourStr, "");
      

  5.   

    这样是不是把table标签也替换掉了呀
    谢谢
      

  6.   


    一次把需求说清楚,别再弄出几个标签来
    Regex reg = new Regex("(?i)<(?!table\b)[^>]*>");
    string result = reg.Replace(yourStr, "");
      

  7.   


    </table>呢?Regex reg = new Regex("(?i)<(?!/?table\b)[^>]*>");
    string result = reg.Replace(yourStr, "");
      

  8.   

            /// <summary>
            /// 清理Word生成的冗余HTML 
            /// </summary>
            /// <param name="html"></param>
            /// <returns></returns>
            public static string CleanWordHtml(string html)
            {
                StringCollection sc = new StringCollection();
                // get rid of unnecessary tag spans (comments and title)
                sc.Add(@"<!--(\w|\W)+?-->");
                sc.Add(@"<title>(\w|\W)+?</title>");
                // Get rid of classes and styles
                sc.Add(@"\s?class=\w+");
                sc.Add(@"\s+style='[^']+'");
                // Get rid of unnecessary tags
                //sc.Add(@"<(meta|link|/?o:|/?style|/?div|/?st\d|/?head|/?html|body|/?body|/?span|!\[)[^>]*?>");
                sc.Add(@"<(meta|link|/?o:|/?style|/?font|/?strong|/?st\d|/?head|/?html|body|/?body|/?span|!\[)[^>]*?>");
                // Get rid of empty paragraph tags
                sc.Add(@"(<[^>]+>)+ (</\w+>)+");
                // remove bizarre v: element attached to <img> tag
                sc.Add(@"\s+v:\w+=""[^""]+""");
                // remove extra lines
                sc.Add(@"(\n\r){2,}");
                foreach (string s in sc)
                {
                    html = Regex.Replace(html, s, "", RegexOptions.IgnoreCase);
                }
                return html;
            }