java正则表达式获取正文中图片、java正则获取正文图片

public static void GetSingleUrl(String content)
    {
   String strPattern = "<img(?:.*)src=(\"{1}|\'{1})([^\\[^>]+[gif|jpg|jpeg|bmp|bmp]*)(\"{1}|\'{1})(?:.*)/>";

   Pattern p=Pattern.compile(strPattern);
          Matcher m=p.matcher(content);
          int j=0;
          while(m.find()){
          j++;
          System.out.println("m.group(" + j + "): " + m.group(0));
          }

结果:

m.group(1): <img alt="" src="http://www.cangyouzj.com/images/upload/Image/zhjyly1.jpg" style="border:0px; margin:0px; padding:0px" />

m.group(2): <img alt="" src="http://www.cangyouzj.com/images/upload/Image/111/xijiezhanshi.jpg" style="border:0px; height:61px; margin:0px; padding:0px; width:935px" />

你可能感兴趣的:(java正则表达式获取正文中图片、java正则获取正文图片)