逛奔的蜗牛

我不聪明,但我会很努力

   ::  :: 新随笔 ::  ::  :: 管理 ::

import java.text.ParseException;

import java.util.regex.Matcher;

import java.util.regex.Pattern;


public class Test {

    public static void main(String[] args) throws ParseException {

        Pattern p = Pattern.compile("(http://)?(([^/ ]+/)+)([^ ]+)");

        Matcher m = p

            .matcher("http://server.php/b/x/123.jpg server/b/x/黄彪.x.jpg server/b/x/Yahoo.jpg");

        while (m.find()) {

            String protocol = m.group(1) == null ? "" : m.group(1);

            System.out.println(protocol + m.group(2) + " => " + m.group(4));

        }

    }

}

posted on 2011-02-24 11:25 逛奔的蜗牛 阅读(574) 评论(0)  编辑 收藏 引用 所属分类: Java

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理