当前位置: 代码迷 >> J2SE >> java获取一段文字中的url地址并且在网页中以链接的方式显示
  详细解决方案

java获取一段文字中的url地址并且在网页中以链接的方式显示

热度:4571   发布时间:2013-02-25 00:00:00.0
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-71b65e66c736http://forum.csdn.net/PointForum/Forum/PostTopic.aspxhttp://forum.csdn.net/PointForum
  相关解决方案