{"id":311,"date":"2021-02-07T16:19:54","date_gmt":"2021-02-07T16:19:54","guid":{"rendered":"http:\/\/robinluo.top\/?p=311"},"modified":"2021-02-07T16:19:54","modified_gmt":"2021-02-07T16:19:54","slug":"%e8%ba%ab%e4%bb%bd%e8%af%81%e5%88%a4%e6%96%ad%e9%80%bb%e8%be%91","status":"publish","type":"post","link":"https:\/\/robinluo.top\/?p=311","title":{"rendered":"\u8eab\u4efd\u8bc1\u5224\u65ad\u903b\u8f91"},"content":{"rendered":"\n<pre class=\"wp-block-preformatted\"><br>\/\/ \u5b9a\u4e49\u5224\u522b\u7528\u6237\u8eab\u4efd\u8bc1\u53f7\u7684\u6b63\u5219\u8868\u8fbe\u5f0f\uff0815\u4f4d\u6216\u800518\u4f4d\uff0c\u6700\u540e\u4e00\u4f4d\u53ef\u4ee5\u4e3a\u5b57\u6bcd\uff09<br>String regularExpression = \"(^[1<strong>-<\/strong>9]\\\\d{5}(18|19|20)\\\\d{2}((0[1<strong>-<\/strong>9])|(10|11|12))(([0<strong>-<\/strong>2][1<strong>-<\/strong>9])|10|20|30|31)\\\\d{3}[0<strong>-<\/strong>9Xx]$)|\" +<br>        \"(^[1<strong>-<\/strong>9]\\\\d{5}\\\\d{2}((0[1<strong>-<\/strong>9])|(10|11|12))(([0<strong>-<\/strong>2][1<strong>-<\/strong>9])|10|20|30|31)\\\\d{3}$)\";<br>\/\/\u5047\u8bbe18\u4f4d\u8eab\u4efd\u8bc1\u53f7\u7801:41000119910101123X  410001 19910101 123X<br>\/\/^\u5f00\u5934<br>\/\/[1-9] \u7b2c\u4e00\u4f4d1-9\u4e2d\u7684\u4e00\u4e2a      4<br>\/\/\\\\d{5} \u4e94\u4f4d\u6570\u5b57           10001\uff08\u524d\u516d\u4f4d\u7701\u5e02\u53bf\u5730\u533a\uff09<br>\/\/(18|19|20)                19\uff08\u73b0\u9636\u6bb5\u53ef\u80fd\u53d6\u503c\u8303\u56f418xx-20xx\u5e74\uff09<br>\/\/\\\\d{2}                    91\uff08\u5e74\u4efd\uff09<br>\/\/((0[1-9])|(10|11|12))     01\uff08\u6708\u4efd\uff09<br>\/\/(([0-2][1-9])|10|20|30|31)01\uff08\u65e5\u671f\uff09<br>\/\/\\\\d{3} \u4e09\u4f4d\u6570\u5b57            123\uff08\u7b2c\u5341\u4e03\u4f4d\u5947\u6570\u4ee3\u8868\u7537\uff0c\u5076\u6570\u4ee3\u8868\u5973\uff09<br>\/\/[0-9Xx] 0123456789Xx\u5176\u4e2d\u7684\u4e00\u4e2a X\uff08\u7b2c\u5341\u516b\u4f4d\u4e3a\u6821\u9a8c\u503c\uff09<br>\/\/$\u7ed3\u5c3e<br><br>\/\/\u5047\u8bbe15\u4f4d\u8eab\u4efd\u8bc1\u53f7\u7801:410001910101123  410001 910101 123<br>\/\/^\u5f00\u5934<br>\/\/[1-9] \u7b2c\u4e00\u4f4d1-9\u4e2d\u7684\u4e00\u4e2a      4<br>\/\/\\\\d{5} \u4e94\u4f4d\u6570\u5b57           10001\uff08\u524d\u516d\u4f4d\u7701\u5e02\u53bf\u5730\u533a\uff09<br>\/\/\\\\d{2}                    91\uff08\u5e74\u4efd\uff09<br>\/\/((0[1-9])|(10|11|12))     01\uff08\u6708\u4efd\uff09<br>\/\/(([0-2][1-9])|10|20|30|31)01\uff08\u65e5\u671f\uff09<br>\/\/\\\\d{3} \u4e09\u4f4d\u6570\u5b57            123\uff08\u7b2c\u5341\u4e94\u4f4d\u5947\u6570\u4ee3\u8868\u7537\uff0c\u5076\u6570\u4ee3\u8868\u5973\uff09\uff0c15\u4f4d\u8eab\u4efd\u8bc1\u4e0d\u542bX<br>\/\/$\u7ed3\u5c3e<br><br><br>boolean matches = IDNumber.matches(regularExpression);<br><br>\/\/\u5224\u65ad\u7b2c18\u4f4d\u6821\u9a8c\u503c<br>if (matches) {<br><br>    if (IDNumber.length() == 18) {<br>        try {<br>            char[] charArray = IDNumber.toCharArray();<br>            \/\/\u524d\u5341\u4e03\u4f4d\u52a0\u6743\u56e0\u5b50<br>            int[] idCardWi = {7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2};<br>            \/\/\u8fd9\u662f\u9664\u4ee511\u540e\uff0c\u53ef\u80fd\u4ea7\u751f\u768411\u4f4d\u4f59\u6570\u5bf9\u5e94\u7684\u9a8c\u8bc1\u7801<br>            String[] idCardY = {\"1\", \"0\", \"X\", \"9\", \"8\", \"7\", \"6\", \"5\", \"4\", \"3\", \"2\"};<br>            int sum = 0;<br>            for (int i = 0; i &lt; idCardWi.length; i++) {<br>                int current = Integer.<em>parseInt<\/em>(String.<em>valueOf<\/em>(charArray[i]));<br>                int count = current * idCardWi[i];<br>                sum += count;<br>            }<br>            char idCardLast = charArray[17];<br>            int idCardMod = sum % 11;<br>            if (idCardY[idCardMod].toUpperCase().equals(String.<em>valueOf<\/em>(idCardLast).toUpperCase())) {<br>                return true;<br>            } else {<br>                return false;<br>            }<br><br>        } catch (Exception e) {<br>            <em>logger<\/em>.error(\"\u8eab\u4efd\u8bc1\u6821\u9a8c\u5f02\u5e38\uff0c{}\", e.getMessage());<br>            return false;<br>        }<br>    }<br><br>}<br><br>return matches;<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\/\/ \u5b9a\u4e49\u5224\u522b\u7528\u6237\u8eab\u4efd\u8bc1\u53f7\u7684\u6b63\u5219\u8868\u8fbe\u5f0f\uff0815\u4f4d\u6216\u800518\u4f4d\uff0c\u6700\u540e\u4e00\u4f4d\u53ef\u4ee5\u4e3a\u5b57\u6bcd\uff09String regularExpression = &#8220;(^[1-9]\\\\d{5}(18|19|20)\\\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\\\d{3}[0-9Xx]$)|&#8221; + &#8220;(^[1-9]\\\\d{5}\\\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\\\d{3}$)&#8221;;\/\/\u5047\u8bbe18\u4f4d\u8eab\u4efd\u8bc1\u53f7\u7801:41000119910101123X 410001 19910101 123X\/\/^\u5f00\u5934\/\/[1-9] \u7b2c\u4e00\u4f4d1-9\u4e2d\u7684\u4e00\u4e2a 4\/\/\\\\d{5} \u4e94\u4f4d\u6570\u5b57 10001\uff08\u524d\u516d\u4f4d\u7701\u5e02\u53bf\u5730\u533a\uff09\/\/(18|19|20) 19\uff08\u73b0\u9636\u6bb5\u53ef\u80fd\u53d6\u503c\u8303\u56f418xx-20xx\u5e74\uff09\/\/\\\\d{2} 91\uff08\u5e74\u4efd\uff09\/\/((0[1-9])|(10|11|12)) 01\uff08\u6708\u4efd\uff09\/\/(([0-2][1-9])|10|20|30|31)01\uff08\u65e5\u671f\uff09\/\/\\\\d{3} \u4e09\u4f4d\u6570\u5b57 123\uff08\u7b2c\u5341\u4e03\u4f4d\u5947\u6570\u4ee3\u8868\u7537\uff0c\u5076\u6570\u4ee3\u8868\u5973\uff09\/\/[0-9Xx] 0123456789Xx\u5176\u4e2d\u7684\u4e00\u4e2a X\uff08\u7b2c\u5341\u516b\u4f4d\u4e3a\u6821\u9a8c\u503c\uff09\/\/$\u7ed3\u5c3e\/\/\u5047\u8bbe15\u4f4d\u8eab\u4efd\u8bc1\u53f7\u7801:410001910101123 410001 910101 123\/\/^\u5f00\u5934\/\/[1-9] \u7b2c\u4e00\u4f4d1-9\u4e2d\u7684\u4e00\u4e2a 4\/\/\\\\d{5} \u4e94\u4f4d\u6570\u5b57 10001\uff08\u524d\u516d\u4f4d\u7701\u5e02\u53bf\u5730\u533a\uff09\/\/\\\\d{2} 91\uff08\u5e74\u4efd\uff09\/\/((0[1-9])|(10|11|12)) 01\uff08\u6708\u4efd\uff09\/\/(([0-2][1-9])|10|20|30|31)01\uff08\u65e5\u671f\uff09\/\/\\\\d{3} \u4e09\u4f4d\u6570\u5b57 123\uff08\u7b2c\u5341\u4e94\u4f4d\u5947\u6570\u4ee3\u8868\u7537\uff0c\u5076\u6570\u4ee3\u8868\u5973\uff09\uff0c15\u4f4d\u8eab\u4efd\u8bc1\u4e0d\u542bX\/\/$\u7ed3\u5c3eboolean matches = IDNumber.matches(regularExpression);\/\/\u5224\u65ad\u7b2c18\u4f4d\u6821\u9a8c\u503cif (matches) { if (IDNumber.length() == 18) { try { char[] charArray = IDNumber.toCharArray(); \/\/\u524d\u5341\u4e03\u4f4d\u52a0\u6743\u56e0\u5b50 int[] idCardWi = {7, 9, 10, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[8],"tags":[44],"_links":{"self":[{"href":"https:\/\/robinluo.top\/index.php?rest_route=\/wp\/v2\/posts\/311"}],"collection":[{"href":"https:\/\/robinluo.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/robinluo.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/robinluo.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/robinluo.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=311"}],"version-history":[{"count":1,"href":"https:\/\/robinluo.top\/index.php?rest_route=\/wp\/v2\/posts\/311\/revisions"}],"predecessor-version":[{"id":312,"href":"https:\/\/robinluo.top\/index.php?rest_route=\/wp\/v2\/posts\/311\/revisions\/312"}],"wp:attachment":[{"href":"https:\/\/robinluo.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=311"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/robinluo.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=311"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/robinluo.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=311"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}