解决方案 »
- 部署在tomcat上的项目,部署没问题,但是运行一段时间后发现tomcat目录下该项目的web.xml文件消失
- 帮帮忙
- 请高手帮忙看看,我哪里错了,关于JAVA用axis调用WebService的问题。
- Hibernate简单问题
- 著名的空指针异常啊 各位高手啊 挑挑这个空指针啊 点击添加按钮进入dispacherAction的add方法 谢谢了啊!!!
- 如何在jboss中设置web目录访问权限?
- 一个未知的疑问
- 这是什么意思?dbTrans.executeUpdate:[Microsoft][ODBC SQL Server Driver]Optional feature not im
- eclipse中java项目转为web项目问题
- Navicat for mysql 新建用户 连接出现1251错误,不是第一次连接数据库
- Eclipse下启动tomcat web程序运行报错但是在tomcat 控制台启动可以运行
- dwr 路径配置
Pattern pattern = Pattern.compile("var friends=(.*);");
Matcher matcher = pattern.matcher(friendPage);
if(matcher.find())
{
String str = matcher.group(1);
System.out.println("friends info: "+ str);
Pattern p = Pattern.compile("/"id/":([1-9][0-9]{0,9})");
Matcher m = p.matcher(str);
while(m.find())
{
friends.add(m.group(1));
}
return friends;
}
Matcher m = p.matcher(s);
if (m.find()) {
System.out.println("xxx:" + m.group(1));
}
正则 怎么写啊。
我这样 取出来的 还是整段
Pattern p = Pattern.compile("src=\'(.*)\'");
Matcher m = p.matcher(html);
while(m.find())
{
imgList.add(m.group(1));
}
难道你只要那个地址链接?'http://XXXXXX'?
如果是只要地址链接最多再做个字符串替换的处理,把"src="替换成空串"",
imgList.add(m.group(1).replaceAll("src=",""));
或者做一下字符串截取不就完事了?
String str="<div class='news_img_box'>" +
"<div class='news_img_image' onclick=\"imgfun(32961292,'http://file.youboy.com/d/158/56/8/7/489817s.jpg')\">" +
"<img onload=changeImg(this,94,94,0) title='20110315(002).jpg' src='http://file.youboy.com/d/158/56/8/7/489817s.jpg' ></div>" +
"<div class='news_img_hover' id='img_hover_32961292' > </div><div class='news_img_name'>20110315(002).jpg</div></div><div class='news_img_box'>" +
"<div class='news_img_image' onclick=\"imgfun(32961291,'http://file.youboy.com/d/158/56/8/0/556180.JPG')\">" +
"<img onload=changeImg(this,94,94,0) title='100_4157.JPG' src='http://file.youboy.com/d/158/56/8/0/556180.JPG' ></div>" +
"<div class='news_img_hover' id='img_hover_32961291' > </div>" +
"<div class='news_img_name'>100_4157.JPG</div></div>" +
"<div class='news_img_box'><div class='news_img_image' onclick=\"imgfun(32961287,'http://file.youboy.com/d/158/56/8/3/757893s.jpg')\">" +
"<img onload=changeImg(this,94,94,0) title='2PY5LLQU63@]V[_(I_)3SEP.jpg' src='http://file.youboy.com/d/158/56/8/3/757893s.jpg' ></div>" +
"<div class='news_img_hover' id='img_hover_32961287' > </div><div class='news_img_name'>2PY5LLQU63@]V[_(I_)3SEP.jpg</div></div>" +
"<div class='news_img_box'><div class='news_img_image' onclick=\"imgfun(32957816,'http://file.youboy.com/d/158/56/8/6/499406s.jpg')\">" +
"<img onload=changeImg(this,94,94,0) title='照片 017.jpg' src='http://file.youboy.com/d/158/56/8/6/499406s.jpg' ></div>" +
"<div class='news_img_hover' id='img_hover_32957816' > </div>" +
"<div class='news_img_name'>照片 017.jpg</div></div><div class='news_img_box'>" +
"<div class='news_img_image' onclick=\"imgfun(32956832,'http://file.youboy.com/d/158/56/8/6/343906s.jpg')\">" +
"<img onload=changeImg(this,94,94,0) title='IMAG0890.jpg' src='http://file.youboy.com/d/158/56/8/6/343906s.jpg' ></div>" +
"<div class='news_img_hover' id='img_hover_32956832' > </div><div class='news_img_name'>IMAG0890.jpg</div></div>" +
"<div class='s_pageDiv'>" +
"<div id='cutpage'>当前页: 1</div><div id='pageCount' >共1页 </div></div>";
Matcher m=Pattern.compile("(?s)(?<=<img).*?src='(.*?)'").matcher(str);
while(m.find())
System.out.println(m.group(1));
刚才没加多个的
Pattern p = Pattern.compile("src=\'(.*?)\'");
Matcher m = p.matcher(str);
while (m.find()) {
System.out.println("xxx:" + m.group(1));
}
}
src=\'(.*?)\' 这个 问号这么重要啊这么弄就对了。可以了。。
这些 matcher 正则什么的 真不懂
SAXReader reader=new SAXReader();
Document doc =reader.reade(new ByteArrayInputStream(str.getBytes("UTF-8")));
XPath x=doc.createXPath("//image");
List<? extends Node> images =x.selectNodes(doc);//获取html中的所有image(Node)对象
for(int i =0;i<images.size();i++){
Element image=(Element)image.get(i);
String src=image.attribute("src");
syso(src);
}