日期:2014-05-20 浏览次数:20850 次
public class Test3{
public static void main(String[] args)
{
System.out.println(getContext2().toString());
}
//正则提取
public static List<String> getContext2() {
//String html="kk<p>123456</p>ssss";
String html="合动力系统车型。<img src=\"http://www.ccstock.cn/2013-03-20/img_114302627951490d84a7d9a.jpg\">匹配不出";
String head="<img src=\"";
String foot="\">";
List<String> resultList = new ArrayList<String>();
Pattern p = Pattern.compile(head+"(.*?)"+foot);//匹配<p>开头,</p>结尾的文档
Matcher m = p.matcher(html );//开始编译
while (m.find()) {
String str=m.group(1);
resultList.add(str);
}
return resultList;
}
}