大家好:
   我把我的问题在说明一下,原帖在这里
http://topic.csdn.net/u/20100119/11/55ca661f-9f06-47f2-9075-5892cf928999.html?27715我说的不是很清楚,11#12#都解决了我的问题。我的意思是如果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>
<TABLE cellSpacing=0 cellPadding=0 border=1>
<TBODY>
<TR>
<TD vAlign=top width=189>
<DIV>分割各付各的</DIV></TD>
<TD vAlign=top width=189>
<DIV>是否</DIV></TD>
<TD vAlign=top width=189>
<DIV>地方</DIV></TD></TR>
<TR>
<TD vAlign=top width=189>
<DIV>&nbsp;地方</DIV></TD>
<TD vAlign=top width=189>
<DIV>地方</DIV></TD>
<TD vAlign=top width=189>
<DIV>&nbsp;地方</DIV></TD></TR>
<TR>
<TD vAlign=top width=189>
<DIV>&nbsp;的地方</DIV></TD>
<TD vAlign=top width=189>
<DIV>地方</DIV></TD>
<TD vAlign=top width=189>
<DIV>&nbsp;得分的</DIV></TD></TR></TBODY></TABLE>

解决方案 »

  1.   


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

  2.   


     string str = "&nbsp;&nbsp; <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> <TABLE cellSpacing=0 cellPadding=0 border=1> <TBODY> <TR> <TD vAlign=top width=189> <DIV>分割各付各的 </DIV> </TD> <TD vAlign=top width=189> <DIV>是否 </DIV> </TD> <TD vAlign=top width=189> <DIV>地方 </DIV> </TD> </TR> <TR> <TD vAlign=top width=189> <DIV>&nbsp;地方 </DIV> </TD> <TD vAlign=top width=189> <DIV>地方 </DIV> </TD> <TD vAlign=top width=189> <DIV>&nbsp;地方 </DIV> </TD> </TR> <TR> <TD vAlign=top width=189> <DIV>&nbsp;的地方 </DIV> </TD> <TD vAlign=top width=189> <DIV>地方 </DIV> </TD> <TD vAlign=top width=189> <DIV>&nbsp;得分的 </DIV> </TD> </TR> </TBODY> </TABLE> ";
            str = Regex.Replace(str, @"<(p)[^>]*>", "</br>", RegexOptions.IgnoreCase);
            str = Regex.Replace(str, @"<(?!/?table)(?!/?tbody)(?!/?tr)(?!/?td)(?!/?br)[^>]*>", "", RegexOptions.IgnoreCase);
            Response.Write(str);
    给分。。
      

  3.   

    楼上的可以(?i)<(?!/?table\b)(?!/?tr\b)(?!/?td\b)[^>]*>
    这样也是可以的谁能给我解释一下
      

  4.   

    (?i) <(?!/?table\b)(?!/?tr\b)(?!/?td\b)[^>]*> 
    (?!/?table\b)遇见<table></table>不匹配
    (?!/?tr\b)遇见<tr></tr>的不匹配
    (?!/?td\b)遇见<td></td>的不匹配
      

  5.   

    (?i) <(?!/?table\b)(?!/?tr\b)(?!/?td\b)> 
    把[^>]*去掉
    [^>]*就是取所有的字符,直到>为止
      

  6.   

    我刚用工具Regex Tester测试了一下,(?i) <(?!/?table\b)(?!/?tr\b)(?!/?td\b)> 任何东西都匹配不出来。
    (?i) <(?!/?table\b)(?!/?tr\b)(?!/?td\b)[^>]*> 
    我想知道,红字部分是什么意思????
      

  7.   

    (?i)匹配时不区分大小写。
    (?!exp) 匹配后面跟的不是exp的位置 
    /?就是说/可有可无
      

  8.   

    不能用匹配要用替换
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Text.RegularExpressions;
    using System.Linq.Expressions;
    using System.Data;
    using System.IO;namespace ConsoleApplication11
    {
        class Program
        {
            static void Main(string[] args)
            {
                string str = @"<TABLE cellSpacing=0 cellPadding=0 border=1> 
    <TBODY> 
    <TR> 
    <TD vAlign=top width=189> 
    <DIV>分割各付各的 </DIV> </TD> 
    <TD vAlign=top width=189> 
    <DIV>是否 </DIV> </TD> 
    <TD vAlign=top width=189> 
    <DIV>地方 </DIV> </TD> </TR> 
    <TR> 
    <TD vAlign=top width=189> 
    <DIV>&nbsp;地方 </DIV> </TD> 
    <TD vAlign=top width=189> 
    <DIV>地方 </DIV> </TD> 
    <TD vAlign=top width=189> 
    <DIV>&nbsp;地方 </DIV> </TD> </TR> 
    <TR> 
    <TD vAlign=top width=189> 
    <DIV>&nbsp;的地方 </DIV> </TD> 
    <TD vAlign=top width=189> 
    <DIV>地方 </DIV> </TD> 
    <TD vAlign=top width=189> 
    <DIV>&nbsp;得分的 </DIV> </TD> </TR> </TBODY> </TABLE> ";
                Regex re = new Regex(@"(?i)<(?!/?table\b)(?!/?tr\b)(?!/?td\b)>");
                Console.WriteLine(re.Replace(str,""));
            }
        }
    }
      

  9.   

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Text.RegularExpressions;
    using System.Linq.Expressions;
    using System.Data;
    using System.IO;namespace ConsoleApplication11
    {
        class Program
        {
            static void Main(string[] args)
            {
                string str = @"<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><TABLE cellSpacing=0 cellPadding=0 border=1> 
    <TBODY> 
    <TR> 
    <TD vAlign=top width=189> 
    <DIV>分割各付各的 </DIV> </TD> 
    <TD vAlign=top width=189> 
    <DIV>是否 </DIV> </TD> 
    <TD vAlign=top width=189> 
    <DIV>地方 </DIV> </TD> </TR> 
    <TR> 
    <TD vAlign=top width=189> 
    <DIV>&nbsp;地方 </DIV> </TD> 
    <TD vAlign=top width=189> 
    <DIV>地方 </DIV> </TD> 
    <TD vAlign=top width=189> 
    <DIV>&nbsp;地方 </DIV> </TD> </TR> 
    <TR> 
    <TD vAlign=top width=189> 
    <DIV>&nbsp;的地方 </DIV> </TD> 
    <TD vAlign=top width=189> 
    <DIV>地方 </DIV> </TD> 
    <TD vAlign=top width=189> 
    <DIV>&nbsp;得分的 </DIV> </TD> </TR> </TBODY> </TABLE> ";
                Regex re = new Regex(@"(?i)<(?!/?table\b)(?!/?tr\b)(?!/?td\b)[^>]*>");
                Console.WriteLine(re.Replace(str,""));
            }
        }
    }要加上[^>]*替换才可以满足你的要求
      

  10.   

    表4.常用分组语法 分类 代码/语法 说明 
    捕获 (exp) 匹配exp,并捕获文本到自动命名的组里 
    (?<name>exp) 匹配exp,并捕获文本到名称为name的组里,也可以写成(?'name'exp) 
    (?:exp) 匹配exp,不捕获匹配的文本,也不给此分组分配组号 
    零宽断言 (?=exp) 匹配exp前面的位置 
    (?<=exp) 匹配exp后面的位置 
    (?!exp) 匹配后面跟的不是exp的位置 
    (?<!exp) 匹配前面不是exp的位置 
    注释 (?#comment) 这种类型的分组不对正则表达式的处理产生任何影响,用于提供注释让人阅读 
    红字部分不是很理解 能举个例子吗??谢谢  今天刚看正则
      

  11.   

    学正则的话还是系统的看客客的blog