去掉HTML标记

 Pattern pattern = Pattern.compile("<.+?>", Pattern.DOTALL);


  Matcher matcher = pattern.matcher("<a href=\"index.html\">主页</a>");
  String string = matcher.replaceAll("");


  System.out.println(string);

 

 

 

 Pattern pattern = Pattern.compile("href=\"(.+?)\"");
  Matcher matcher = pattern.matcher("<a href=\"index.html\">主页</a>");
  if(matcher.find())
  System.out.println(matcher.group(1));

你可能感兴趣的:(html)