日期:2014-05-19 浏览次数:20839 次
public class Test05 {
static String str = "<li class=\"item\"><a onclick=\"\" href=\"/attraction_review-d19-s64844-05p1-huangshanfengjingqu.html\">很好</a><span class=\"rank-bar\"><em style=\"width: 80px\"></em></span><a onclick=\"\" href=\"/attraction_review-d19-s64844-05p1-huangshanfengjingqu.html\">8</a></li><li class=\"item\"><a onclick=\"\" href=\"/attraction_review-d19-s64844-04p1-huangshanfengjingqu.html\">较好</a><span class=\"rank-bar\"><em style=\"width: 10px\"></em></span><a onclick=\"\" href=\"/attraction_review-d19-s64844-04p1-huangshanfengjingqu.html\">1</a></li><li class=\"item\"><span class=\"fake-a\">一般</span><span class=\"rank-bar\"><em style=\"width: 0px\"></em></span><span class=\"fake-a\">0</span></li><li class=\"item\"><a onclick=\"\" href=\"/attraction_review-d19-s64844-02p1-huangshanfengjingqu.html\">较差</a><span class=\"rank-bar\"><em style=\"width: 10px\"></em></span><a onclick=\"\" href=\"/attraction_review-d19-s64844-02p1-huangshanfengjingqu.html\">1</a></li><li class=\"item\"><span class=\"fake-a\">很差</span><span class=\"rank-bar\"><em style=\"width: 0px\"></em></span><span class=\"fake-a\">0</span></li></ul></div></div>";
//[很好 , 较好 , 较差 ] 都用这个方法
static String findA(String key){
String regexp = "<a.*?href=\"(.*?)\".*?>" + key + "</a>.*?<a.*?href=\"(\\1)\".*?>(.*?)</a>";
Matcher m = Pattern.compile(regexp).matcher(str);
if(m.find()){