日期:2014-05-18 浏览次数:20534 次
<table border="0" bgcolor="#0033cc" cellspacing="1" cellpadding="0" width="500" align="center"> <tr bgcolor="#ffffff"> <td align="center" height="18">这里是内容</td> </tr> </table>
<table> <tr> <td>这里是内容</td> </tr> </table>
using System;
using System.Text.RegularExpressions;
class Program
{
static void Main()
{
string s0 = @"
<table border=""0"" bgcolor=""#0033cc"" cellspacing=""1"" cellpadding=""0"" width=""500"" align=""center"">
<tr bgcolor=""#ffffff"">
<td align=""center"" height=""18""><a href=""."">这里是内容</a></td>
</tr>
</table>";
string s1 = Regex.Replace(s0, @"(?i)<(table|tr|td)(?:\s+(?:""[^""]*""|'[^']*'|[^""'>])*)?>", "<$1>");
Console.WriteLine(s1);
}
}
/* 程序输出:
<table>
<tr>
<td><a href=".">这里是内容</a></td>
</tr>
</table>
*/