日期:2014-05-18 浏览次数:20695 次
package com.huida.mypoi; import java.util.regex.*; public class MyTest { public static void main(String args[]){ String s= " <img src=http://www.hao123.com/jpg.jpg'>" +" <img src='http://www.google.com/gif.jpg'>" +"888888888dfdsfsfafhttp://www.google.com/jpg.jpg" +"http://www.google.com/jpg.jpg" +"不显示hao123网的图片 包含两种情况(" +"http://www.hao123.com/xxx.jpg 或者http://hao123.com/xxx.jpg"; String sReg="http://(.*?)\\.jpg"; Pattern pattern=Pattern.compile(sReg); Matcher matcher=pattern.matcher(s); String sImgName; while(matcher.find()){ sImgName=matcher.group(); if(sImgName.indexOf("hao123")==-1) System.out.println(matcher.group()); } } }