{"id":668,"date":"2018-12-14T16:33:35","date_gmt":"2018-12-14T08:33:35","guid":{"rendered":"https:\/\/www.dd-home.top\/?p=668"},"modified":"2018-12-14T16:33:35","modified_gmt":"2018-12-14T08:33:35","slug":"string-%e5%ad%97%e7%ac%a6%e4%b8%b2%e6%9b%bf%e6%8d%a2","status":"publish","type":"post","link":"https:\/\/www.dd-home.top\/?p=668","title":{"rendered":"String \u5b57\u7b26\u4e32\u66ff\u6362&#8217;*&#8217;"},"content":{"rendered":"<pre class=\"lang:java decode:true  \">\/**\n     * \u5b9e\u9645\u66ff\u6362\u52a8\u4f5c\n     *\n     * @param str str\n     * @return\n     *\/\n    public static String replaceAction(String str) {\n        if(isEmpty(str)){\n            return \"\";\n        }\n        String afterReplaced = \"\";\n        int nameLength = str.length();\n        if (nameLength &lt; 3 &amp;&amp; nameLength &gt; 0) {\n            if (nameLength == 1) {\n                afterReplaced = \"*\";\n            } else {\n                afterReplaced = str.substring(0,1)+\"*\";\n            }\n        } else {\n            Integer num1, num2, num3;\n            num2 = (new Double(Math.ceil(new Double(nameLength) \/ 3))).intValue();\n            num1 = (new Double(Math.floor(new Double(nameLength) \/ 3))).intValue();\n            num3 = nameLength - num1 - num2;\n            String star = org.apache.commons.lang3.StringUtils.repeat(\"*\", num2);\n            afterReplaced = str.replaceAll(\"(.{\" + num1 + \"})(.{\" + num2 + \"})(.{\" + num3 + \"})\", \"$1\" + star + \"$3\");\n        }\n        return afterReplaced;\n    }<\/pre><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\/** * \u5b9e\u9645\u66ff\u6362\u52a8\u4f5c * * @param str str * @return *\/ public sta &hellip; <a href=\"https:\/\/www.dd-home.top\/?p=668\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">String \u5b57\u7b26\u4e32\u66ff\u6362&#8217;*&#8217;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20,1],"tags":[61],"class_list":["post-668","post","type-post","status-publish","format-standard","hentry","category-java","category-uncategorized","tag-61"],"_links":{"self":[{"href":"https:\/\/www.dd-home.top\/index.php?rest_route=\/wp\/v2\/posts\/668","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dd-home.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dd-home.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dd-home.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dd-home.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=668"}],"version-history":[{"count":0,"href":"https:\/\/www.dd-home.top\/index.php?rest_route=\/wp\/v2\/posts\/668\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.dd-home.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=668"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dd-home.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=668"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dd-home.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=668"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}