日期:2014-05-17  浏览次数:20742 次

求一个超链接的正则表达式
我想要一个能够匹配任意一个超链接的正则表达式 该如何写啊

------解决方案--------------------
public static String findHrefUrl(String str) {
String regxp = "href=[\'\"]([\\w\\d\\.:/?=&;-[#]]*)[\'\"]";
Pattern pattern = Pattern.compile(regxp);
Matcher matcher = pattern.matcher(str);
String result = "";
while( matcher.find()){
result = matcher.group();
int i = result.indexOf("\"");
if (i == -1){
String[] asStr = result.split("\'");
return asStr[1];
} else {
String[] asStr = result.split("\"");
return asStr[1];
}
}
return null;
}
------解决方案--------------------
<a.*?href=(?:\"|')(.*?)(?:\"|').*?>.*?</a>