注:本文转载于:http://blog.sina.com.cn/s/blog_600ff07501014lgb.html
Pattern pattern = Pattern.compile("<(\\S+?)\\s+(?:\"[^\"]*\"|'[^']*'|[^\"'><])+>(.+?)</\\1>");
Matcher matcher = pattern.matcher("<a href=\"http://baidu.com\">这是连接文字 </a><a οnclick=\"alert(1)\" href=\"http://baidu.com\">这是连接文字2</a>");
while(matcher.find()) {
if(matcher.groupCount() > 1)
System.out.println(matcher.group(2));
}