我想使用oro包查找出来sina.com主页中的.jpg文件
String html = IOUtils.toString(new URL("http://www.sina.com").openStream());
正则的字符串我是这样想的,可能有疏忽的地方,但是能匹配绝大部分。
String picReg = "http://[\\S]*+\\.jpg";
Perl5Compiler compiler = new Perl5Compiler();
Perl5Matcher matcher = new Perl5Matcher();
PerlMatcherInput inputContent = new PerlMatcherInput(html);
Pattern pattern = compiler.compile(picReg);
while(matcher.contains(inputContent,pattern)) {
MatchResult result = matcher.getMatch();
System.out.println(result);
}
这样就都找出来了。把这篇文章写下来,以后忘了我就来看。
apache的东西就是好用。很好很强大。