日期:2014-05-20  浏览次数:20779 次

关于java的正则表达式问题
有个字符串如下:
class="tag-item">成都地铁打人女</a> </li>     <li 0 >  </li>     <li 0 > <a data-nsclick="p=index&event_type=hotquery.click&hotquery=%E6%B1%9F%E8%8B%8F%E5%A4%A9%E4%B8%8A%E4%BA%BA%E9%97%B4" target="_blank" href="/i?fr=hotindex&tn=baiduimage&ct=201326592&lm=-1&cl=2&nc=1&ie=utf-8&word=%E6%B1%9F%E8%8B%8F%E5%B8%B8%E7%86%9F%E5%A4%A9%E4%B8%8A%E4%BA%BA%E9%97%B4" class="tag-item">江苏天上人间</a> </li>     <li 0 >  </li>     <li 1 class="hot"> <a data-nsclick="p=index&event_type=hotquery.click&hotquery=%E9%83%AD%E7%BE%8E%E7%BE%8E%E6%B3%B3%E8%A3%85%E7%85%A7" target="_blank" href="/i?fr=hotindex&tn=baiduimage&ct=201326592&lm=-1&cl=2&nc=1&ie=utf-8&word=%E9%83%AD%E7%BE%8E%E7%BE%8E%E5%86%8D%E6%99%92%E6%B3%B3%E8%A3%85%E7%85%A7" class="tag-item"></a> </li> 

我想用从里面抽取出来“成都地铁打人女”,“江苏天上人间”,“郭美美泳装照”这三个关键词,该如何在java中实现?

------解决方案--------------------
(?<=class="tag-item">)[^<>]+(?=</a>)
------解决方案--------------------
还是这个看着舒服点。。
public static void main(String[] arg) {
List<String> imgList = new ArrayList<String>();
String intputStr = "class=\"tag-item\">成都地铁打人女</a> </li>  " +
"   <li 0 >  </li>     <li 0 > " +
"<a data-nsclick=\"p=index&event_type=hotquery.click&hotquery=%E6%B1%9F%E8%8B%8F%E5%A4%A9%E4%B8%8A%E4%BA%BA%E9%97%B4\" target=\"_blank\" href=\"/i?fr=hotindex&tn=baiduimage&ct=201326592&lm=-1&cl=2&nc=1&ie=utf-8&word=%E6%B1%9F%E8%8B%8F%E5%B8%B8%E7%86%9F%E5%A4%A9%E4%B8%8A%E4%BA%BA%E9%97%B4\"" +
" class=\"tag-item\">江苏天上人间</a> </li>     <li 0 >  </li>     <li 1 class=\"hot\">" +
" <a data-nsclick=\"p=index&event_type=hotquery.click&hotquery=%E9%83%AD%E7%BE%8E%E7%BE%8E%E6%B3%B3%E8%A3%85%E7%85%A7\" target=\"_blank\" " +