正则 <img src="image/icons/cloudday_small.gif" width="20" height="20">dfsdf<img src="image/icons/cloudday_454.gif" width="20" height="20">怎么样通过正则把图片的地址取出 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 希望没错...<SCRIPT LANGUAGE="JavaScript" defer><!-- var imgStr = '<img src="image/icons/cloudday_small.gif" width="20" height="20">dfsdf<img src="image/icons/cloudday_454.gif" width="20" height="20">'; imgStr.match(/src=\"([^\"]*)/gi); alert(RegExp.$1); //--></SCRIPT> 试试这样?String s = "<img src=\"image/icons/cloudday_small.gif\" width=\"20\"" + "height=\"20\">dfsdf<img src=\"image/icons/cloudday_454.gif\"" + "width=\"20\" height=\"20\">\"";Pattern pattern = Pattern.compile("<img\\s+src=\\\"([^\"]+)\".*");Matcher match = pattern.matcher(s);String url = null;if(match.matches()) { url = match.group(1);} String s = "<img src=\"image/icons/cloudday_small.gif\" width=\"20\" height=\"20\">dfsdf<img src=\"image/icons/cloudday_454.gif\" width=\"20\" height=\"20\">";Matcher m = Pattern.compile("src=\"?(.*?)(\"|>|\\s+)").matcher(s);while(m.find()){ System.out.println(m.group(1));} 如何获取年份 如何向客户隐蔽struts 俺要驱动老大们。。。。。 一个难找到错误的问题: 大伙帮忙看看这段代码哪里有错 Java Web后台通过request.getParameter( )方法得到的字符串显示为乱码 ServletContext的获取问题 如何在Tomcat中设置错误页 有学习structs的吗,推荐一下好书,和学习经验,多谢 我回答问题得分了,但为什么总分不增加啊?分不多,在线揭帖 这段代码为什么会出错误 struts 下拉列表问题
<SCRIPT LANGUAGE="JavaScript" defer>
<!--
var imgStr = '<img src="image/icons/cloudday_small.gif" width="20" height="20">dfsdf<img src="image/icons/cloudday_454.gif" width="20" height="20">';
imgStr.match(/src=\"([^\"]*)/gi);
alert(RegExp.$1);
//-->
</SCRIPT>
"height=\"20\">dfsdf<img src=\"image/icons/cloudday_454.gif\"" +
"width=\"20\" height=\"20\">\"";
Pattern pattern = Pattern.compile("<img\\s+src=\\\"([^\"]+)\".*");
Matcher match = pattern.matcher(s);
String url = null;
if(match.matches()) {
url = match.group(1);
}
Matcher m = Pattern.compile("src=\"?(.*?)(\"|>|\\s+)").matcher(s);
while(m.find())
{
System.out.println(m.group(1));
}