日期:2014-05-19  浏览次数:20476 次

正则表达式的问题,麻烦大家看看
re   =   new   Regex(@ " <td   width= " "84% " "   height= " "25 " "> <font> .*?\n(? <Content> [^\n]*?) </font> </td> ",   RegexOptions.Singleline|RegexOptions.Compiled);
  a.ArtContent   =   re.Match(info).Groups[ "Content "].Value;
匹配这个
  <td   width= "84% "   height= "25 ">   <font>  
                                      汉字部分。                                         </font>   </td>
为什么匹配不到啊。
很奇怪。
我就这么多分,大家帮帮忙


------解决方案--------------------
string info=@ " <td width= " "84% " " height= " "25 " "> <font> 汉字部分。 </font> </td> "; Regex re = new Regex(@ " <td width= " "84% " " height= " "25 " "> \s* <font> .*?\n(? <Content> [^\n]*?) </font> \s* </td> ", RegexOptions.Singleline | RegexOptions.Compiled); Response.Write(re.Match(info).Groups[ "Content "].Value);
------解决方案--------------------
= " "25 " "> 和 <font> 之间, </font> 和 </td> 之间分别少了一个空格,这些为普通字符,要匹配一定要全部匹配,或者是在其中间加\s*