{"id":7969,"date":"2024-03-29T17:53:16","date_gmt":"2024-03-29T09:53:16","guid":{"rendered":"https:\/\/white-night.club\/?p=7969"},"modified":"2024-03-29T18:01:45","modified_gmt":"2024-03-29T10:01:45","slug":"ad170","status":"publish","type":"post","link":"https:\/\/white-night.club\/index.php\/2024\/03\/29\/ad170\/","title":{"rendered":"520. \u68c0\u6d4b\u5927\u5199\u5b57\u6bcd"},"content":{"rendered":"\n<p><a href=\"https:\/\/leetcode.cn\/problems\/detect-capital\/\">https:\/\/leetcode.cn\/problems\/detect-capital\/<\/a><\/p>\n\n\n\n<p>\u8bd5\u7740\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u5199\u4e86\u5199\uff0c\u8fd8\u633a\u9ebb\u70e6\u7684\u3002<\/p>\n\n\n\n<p>\u5148Compile\u6216\u8005\u76f4\u63a5\u7528MatchString\u90fd\u884c\u3002\u800c\u201c$\u201c\u7528\u4e8e\u8868\u793a\u4e00\u4e2a\u6b63\u5219\u8868\u8fbe\u5f0f\u7684\u7ed3\u675f\uff0c\u5fc5\u4e0d\u53ef\u5c11\u3002\u5339\u914d\u7684\u8bdd\u65e0\u975e\u5c31\u4e09\u79cd\uff1a\u5168\u5927\u5199\uff1b\u5168\u5c0f\u5199\uff1b\u53ea\u6709\u5f00\u5934\u5b57\u6bcd\u5927\u5199\u3002<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#2b2b2b;color:#c7c7c7\">Go<\/span><span role=\"button\" tabindex=\"0\" data-code=\"import &quot;regexp&quot;\nfunc detectCapitalUse(word string) bool {\n    match,_ := regexp.MatchString(`(?:^[A-Z]+$|^[a-z]+$|^[A-Z][a-z]+$)$`,word)\n\t  return match\n}\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #569CD6\">import<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #CE9178\">&quot;regexp&quot;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #569CD6\">func<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #DCDCAA\">detectCapitalUse<\/span><span style=\"color: #D4D4D4\">(word <\/span><span style=\"color: #4EC9B0\">string<\/span><span style=\"color: #D4D4D4\">) <\/span><span style=\"color: #4EC9B0\">bool<\/span><span style=\"color: #D4D4D4\"> {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #9CDCFE\">match<\/span><span style=\"color: #D4D4D4\">,<\/span><span style=\"color: #9CDCFE\">_<\/span><span style=\"color: #D4D4D4\"> := regexp.<\/span><span style=\"color: #DCDCAA\">MatchString<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #CE9178\">`(?:^[A-Z]+$|^[a-z]+$|^[A-Z][a-z]+$)$`<\/span><span style=\"color: #D4D4D4\">,word)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">\t  <\/span><span style=\"color: #C586C0\">return<\/span><span style=\"color: #D4D4D4\"> match<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">}<\/span><\/span><\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u6b63\u5219\u8868\u8fbe\u5f0f+\u5185\u7f6e\u51fd\u6570<\/p>\n","protected":false},"author":1,"featured_media":7932,"comment_status":"open","ping_status":"","sticky":false,"template":"base","format":"standard","meta":{"footnotes":""},"categories":[42,25],"tags":[38],"_links":{"self":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/7969"}],"collection":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/comments?post=7969"}],"version-history":[{"count":0,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/7969\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/media\/7932"}],"wp:attachment":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/media?parent=7969"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/categories?post=7969"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/tags?post=7969"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}