Java 正则表达式查找html中A标签地址

查找html中A标签地址

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

截取A标签中地址

Pattern pattern = Pattern.compile("(http://|https://){1}[//w//.//-/:]+");
Matcher matcher = pattern.matcher("dsdsds<http://dsds//gfgffdfd>fdf");
StringBuffer buffer = new StringBuffer();
while(matcher.find()){              
    buffer.append(matcher.group());        
    buffer.append("/r/n");              
    System.out.println(buffer.toString());
}