我有像贝洛一样的HTML
<html lang="en">
<head>
<meta http-equiv ...............
...................
</head> ..............
...............
</html>
我想用&#34;&#34;(空)替换<head>.....</head>
,最终字符串应该如下所示
<html lang="en">..............
....................
</html>
我试过这个,但没有运气没有改变。任何帮助表示赞赏
myStr= myStr.replaceAll("^<head>.*</head>$", "");
System.out.println(myStr);
答案 0 :(得分:1)
答案 1 :(得分:0)
试试这个
String replStr = "<head>\\s*([\\s\\S]*?)\\s*</head>";
String yourHtml = "<html> <head> <meta http-equiv ............</head></html>";
yourHtml = yourHtml.replaceAll(replStr, "");
System.out.println("Ans : "+yourHtml);