import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class RegTest {
public static void main(String[] args) {
String tar = "asdflknaslknsadfisadnfsdfnsdfns<img src=\"a.jpg\">sdfasd" +
    "fsadfsnn<img src=\"b.gif\">adsfsadf" +
    "sflsadkfnsdalkfnsdalknf<img src=\"c.bmp\">safnsadflnke";
List<String> imgList = getImg(tar);
for (String string : imgList) {
   int begin = string.indexOf("\"")+1;
   int end = string.lastIndexOf("\"");
   System.out.println(string.substring(begin,end));
}

}
/** 
   *   
   * @param s 
   * @return »ñµÃͼƬ
   */ 
public static List<String> getImg(String s)   
{   
   String regex;   
   List<String> list = new ArrayList<String>();   
   regex = "src=\"(.*?)\"";   
   Pattern pa = Pattern.compile(regex, Pattern.DOTALL);   
   Matcher ma = pa.matcher(s);   
   while (ma.find())   
   {
    list.add(ma.group());   
   }   
   return list;   
}   
} 
 

最近下载更多
JiangBigPan  LV16 2020年8月27日
叶林青  LV3 2019年1月31日
zf_mmp  LV1 2018年11月22日
紫极20  LV1 2018年9月12日
z924931408  LV25 2018年6月6日
星空蓝色调  LV4 2018年6月3日
走掉的旋律  LV8 2017年11月10日
d13528314  LV2 2017年8月22日
lishiqiang1990  LV5 2017年1月3日
zyl  LV34 2016年6月5日
最近浏览更多
JiangBigPan  LV16 2020年8月27日
特有的温柔带点涩i  LV6 2020年6月26日
余多多 2020年6月12日
暂无贡献等级
安添霁  LV1 2020年4月30日
lyy59216  LV1 2019年6月27日
728649191  LV1 2019年4月14日
叶林青  LV3 2019年1月31日
kingdoms2008 2018年11月23日
暂无贡献等级
zf_mmp  LV1 2018年11月22日
964886154  LV1 2018年11月21日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友