去除html标记
pattern pattern = pattern.compile("<.+?>", pattern.dotall);
matcher matcher = pattern.matcher("<a href="index.html">主页</a>");
string string = matcher.replaceall("");
system.out.println(string);
查找html中对应条件字符串
pattern pattern = pattern.compile("href="(.+?)"");
matcher matcher = pattern.matcher("<a href="index.html">主页</a>");
if(matcher.find())
system.out.println(matcher.group(1));
}
时间: 2024-10-11 13:50:40