日期:2014-05-20  浏览次数:20799 次

java获取一段文字中的url地址并且在网页中以链接的形式显示
java获取一段文字中的url地址并且http://forum.csdn.net/PointForum/Forum/PostTopic.aspx?forumID=467d91e3-dd10-480b-a322-71b65e66c736在网页中以链接http://forum.csdn.net/PointForum/Forum/PostTopic.aspx的形式显示发生的发生大幅飞洒放到http://forum.csdn.net/PointForum

在网页显示如下:

java获取一段文字中的url地址并且http://forum.csdn.net/PointForum/Forum/PostTopic.aspx?forumID=467d91e3-dd10-480b-a322-71b65e66c736在网页中以链接http://forum.csdn.net/PointForum/Forum/PostTopic.aspx的形式显示发生的发生大幅飞洒放到http://forum.csdn.net/PointForum



------解决方案--------------------
lucene切词,好像没别的办法了
------解决方案--------------------
Java code

    public static void main(String[] args) {
        String s = "java获取一段文字中的url地址并且Http://forum.csdn.net/PointForum/Forum/PostTopic.aspx?forumID=467d91e3-dd10-480b-a322-71b65e66c736在网页中以链接http://forum.csdn.net/PointForum/Forum/PostTopic.aspx的形式显示发生的发生大幅飞洒放到http://forum.csdn.net/PointForum";
        Matcher m = Pattern.compile("(?i)http://[^\u4e00-\u9fa5]+").matcher(s);
        while(m.find()){
            System.out.println(m.group());
        }
    }

运行结果:
Http://forum.csdn.net/PointForum/Forum/PostTopic.aspx?forumID=467d91e3-dd10-480b-a322-71b65e66c736
http://forum.csdn.net/PointForum/Forum/PostTopic.aspx
http://forum.csdn.net/PointForum