使用apache oro 正则

我想使用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的东西就是好用。很好很强大。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值