public int getPageNum(){
int num = 1;
String s="(?<=<a href=(\\u0022)http://club.360buy.com/review/\\d{6,}-1-\\d{1,}-\\d{1}.html(\\u0022)>)\\d{1,}(?=</a><a href=(\\u0022)http://club.360buy.com/review/\\d{6,}-1-\\d{1,}-\\d{1}.html(\\u0022)>下一页&raquo;</a></div>)";
Pattern p=Pattern.compile(s);
Matcher m=p.matcher("<div class="Pagination"><a class="current" href="http://club.360buy.com/review/127011-1-1-3.html">1</a><a href="http://club.360buy.com/review/127011-1-2-3.html">2</a><a href="http://club.360buy.com/review/127011-1-8-3.html">8</a><a href="http://club.360buy.com/review/127011-1-9-3.html">9</a><a href="http://club.360buy.com/review/127011-1-2-3.html">下一页&raquo;</a></div>");
while(m.find())
{
num=Integer.parseInt(m.group());
break;
}
System.out.println("页面总数:"+num);
return num;
}
报错内容是:Exception in thread "main" java.util.regex.PatternSyntaxException: Look-behind group does not have an obvious maximum length near index 84
还有个^指在正则表达式的="(?<=<a href=(\\u0022)http://club.360buy.com/review/\\d{6,}-1-\\d{1,}-\\d{1}.html(\\u0022)>)最后的>处,不懂为什么,求教?