그림 을 캡 처 하 는 url

1301 단어 url
import java.util.regex.Matcher;
import java.util.regex.Pattern;


public class MatchTest {
	
	public static void main(String[] args) {
		String a = "aaaa<img src=\"http://www.baidu.com/img/baidu_sylogo1.gif\"aaaa" +
		"aaaa<img src=\"http://www.baidu.com/img/baidu_sylogo1.gif\"aaaa";
//1		Pattern p = Pattern.compile("<img src=\".*\"");
		Pattern p = Pattern.compile("<img.*?src=\"(.*?)\"");  //()    
		Matcher m = p.matcher(a);
		while (m.find()){
//			System.out.println(m.group());
//			<img src="http://www.baidu.com/img/baidu_sylogo1.gif"
//			<img src="http://www.baidu.com/img/baidu_sylogo1.gif"
			
			System.out.println(m.group(1));
//			http://www.baidu.com/img/baidu_sylogo1.gif
//			http://www.baidu.com/img/baidu_sylogo1.gif
		}
//1		<img src="http://www.baidu.com/img/baidu_sylogo1.gif"aaaaaaaa<img src="http://www.baidu.com/img/baidu_sylogo1.gif"
		
//		<img src="http://www.baidu.com/img/baidu_sylogo1.gif"
//		<img src="http://www.baidu.com/img/baidu_sylogo1.gif"
	}

}

좋은 웹페이지 즐겨찾기