截取html中的某个节点

String content = "<meta property=\"og:description\" content=\"freeCodeCamp Earth &#x6709; 127,712 &#x4f4d;&#x6210;&#x54e1;&#x3002; Welcome to freeCodeCamp Earth!\n" +
                "\n" +
                "This is a relaxing place to discuss coding and share your accomplishments.\n" +
                "\n" +
                "To keep this Facebook group civil, our moderator team...\" />\n" +
                "\t<meta property=\"og:url\" content=\"https://www.facebook.com/groups/321090721625587/\" />\n" +
                "\t<meta property=\"og:locale\" content=\"en_US\" />";
        String readText = "";
//        Pattern p = Pattern.compile("<div\\s*class=[\"']mail-trace[\"'](.*)>(.*)<\\/div>");
        Pattern p = Pattern.compile("<meta\\s*property=[\"']og:url[\"'](.*)(.*)\\/>");
        Matcher matcher = p.matcher(content);
        if (matcher.find()) {
            for (int i = 0; i <= matcher.groupCount() && StringUtils.isEmpty(readText); i++) {
                readText += matcher.group(i);
            }
        }
        System.out.println(readText);

 

<meta property="og:description" content="freeCodeCamp Earth &#x6709; 127,712 &#x4f4d;&#x6210;&#x54e1;&#x3002; Welcome to freeCodeCamp Earth!

This is a relaxing place to discuss coding and share your accomplishments.

To keep this Facebook group civil, our moderator team..." />
    <meta property="og:url" content="https://www.facebook.com/groups/321090721625587/" />     要匹配内容!
    <meta property="og:locale" content="en_US" />

 

posted @ 2020-09-09 13:55  wanhua.wu  阅读(185)  评论(0编辑  收藏  举报