取出 字符串中的 网址

    public static void main(String[] args) {
        String url = "小人书123网 dddddhttp://www.xiaorenshu123.com/entry/4545/0/?a=3张国";
        // url = "abc";
        getUrl(url);
    }


    public static String getUrl(String input) {
        String regex = "(http://.*?)[\\s\u4e00-\u9fa5]";
        Pattern pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
        Matcher matcher = pattern.matcher(input);
        if (matcher.find()) {
            System.out.println(matcher.group(1));
            return matcher.group(1);
        }
        return "";
    }



猜你喜欢

转载自wentao365.iteye.com/blog/1958527