String str = '<img src="11.jpg" /><img width="100" height="20" src="22.gif" /><img width="100" src="33.gif" height="20" />'我想要获取srt里所有img属性的图片文件,
取出的结果是11.jpg,22.gif.33.gif
分不多了,只有100分全给了

解决方案 »

  1.   

    <img src="image/index.jpg" onload="javascript:if(this.width>500) this.width=500;">
    上面的已经可以起到宽高都按比例缩小,不过你也可自己进行设定:
    <img src="image/index.jpg" onload="javascript:if(this.width>500){this.height*=500/this.width;this.width=500;}">
    你看看这样可以吗???
      

  2.   

    你就把它当做一个XML来解析吧,dom4j来搞。
      

  3.   

    用正则表达式很好做.String str = "<img src='11.jpg' /><img width='100' height='20' src='22.gif' /><img width='100' src='33.gif' height='20' />";
    String regex = "\\<img[^\\<|^\\>]*src=[\\'|\\'\\']([^\\<|^\\>]*\\.{1}[^\\<|^\\>]{0,4})[\\'|\\'\\'][^\\<|^\\>]*[\\>|\\/\\>]";
    Pattern p = Pattern.compile(regex);
    Matcher m = p.matcher(str);
    while(m.find()){
       System.out.println(m.group(1));
    }
    代码通过测试,应该没问题.