求指教如何使用正则表达式从一段html文本中去除所有<embed></embed>标签、得到剩余的html。
如 <html>
<head>
<title>测试</title>
</head
<body>
     <p>fsgdfgvdsfgdfshgbdsfgsfdgfdgfd</p>
<div id="player404352-parent" style="text-align: center">&nbsp;</div>
注,因该医院楼顶建有停机坪、大厅内有价值&lt;a href=&quot;http://news.sina.com.cn/c/2012-11-<br />
<embed height="400" width="400" src="/DailyHG/userfiles/flash/efe50077-6767-4cde-a716-67d124e130e1.swf" type="application/x-shockwave-flash" play="true" loop="true" menu="true"></embed>
<br />
</body>
</html>去除embed标签后、就是下面这样、<html>
<head>
<title>测试</title>
</head
<body>
     <p>fsgdfgvdsfgdfshgbdsfgsfdgfdgfd</p>
<div id="player404352-parent" style="text-align: center">&nbsp;</div>
注,因该医院楼顶建有停机坪、大厅内有价值&lt;a href=&quot;http://news.sina.com.cn/c/2012-11-<br />
<br />
</body>
</html>求指教如何写

解决方案 »

  1.   

    <embed[^\n]*?></embed>
      

  2.   


    String content = "<html>\r\n"
    + "<head>\r\n"
    + "<title>测试</title>\r\n"
    + "</head>\r\n"
    + "<body>\r\n"
    + "<p>fsgdfgvdsfgdfshgbdsfgsfdgfdgfd</p>\r\n"
    + "<div id=\"player404352-parent\" style=\"text-align: center\">&nbsp;</div>\r\n"
    + "注,因该医院楼顶建有停机坪、大厅内有价值&lt;a href=&quot;http://news.sina.com.cn/c/2012-11-<br />\r\n"
    + "<embed height=\"400\" width=\"400\" src=\"/DailyHG/userfiles/flash/efe50077-6767-4cde-a716-67d124e130e1.swf\" type=\"application/x-shockwave-flash\" play=\"true\" loop=\"true\" menu=\"true\"></embed>\r\n"
    + " <br />\r\n" + "</body>\r\n" + "</html>\r\n";
    System.out.println(content.replaceAll("<embed[^\n]*?></embed>", ""));
      

  3.   

    个人认为:<embed[^>]+></embed>.*\r\n 要好些
      

  4.   

    :<embed[^>]+?></embed>.*\r\n
      

  5.   


    c#是用Regex这个类操作的..Java不清楚了..查一查..